@@ -103,7 +103,7 @@ Object.assign(pc, function () {
103
103
104
104
this . _outlineColor = new pc . Color ( 0 , 0 , 0 , 1 ) ;
105
105
this . _outlineColorUniform = new Float32Array ( 4 ) ;
106
- this . _outlineThicknessScale = 0.2 ; // coefficient to map editor range of 0 - 1 to shader value
106
+ this . _outlineThicknessScale = 0.2 ; // 0.2 coefficient to map editor range of 0 - 1 to shader value
107
107
this . _outlineThickness = 0.0 ;
108
108
109
109
this . _multiPassEnabled = false ; // when true multi pass text rendering is enabled for correct thicker outline rendering
@@ -114,8 +114,6 @@ Object.assign(pc, function () {
114
114
this . _shadowOffset = new pc . Vec2 ( 0 , 0 ) ;
115
115
this . _shadowOffsetUniform = new Float32Array ( 2 ) ;
116
116
117
- this . _zeroColorUniform = new Float32Array ( 4 ) ;
118
-
119
117
this . _enableMarkup = false ;
120
118
121
119
// initialize based on screen
@@ -461,20 +459,16 @@ Object.assign(pc, function () {
461
459
462
460
meshInfo . count = l ;
463
461
464
- switch ( this . _meshInfo [ i ] . renderPass ) {
465
- case RenderPass . TEXT :
466
- case RenderPass . ALL_IN_ONE :
467
- meshInfo . positions . length = meshInfo . normals . length = l * 3 * 4 ;
468
- meshInfo . indices . length = l * 3 * 2 ;
469
- meshInfo . uvs . length = l * 2 * 4 ;
470
- meshInfo . colors . length = l * 4 * 4 ;
471
- break ;
472
- default :
473
- meshInfo . positions . length = meshInfo . normals . length = 0 ;
474
- meshInfo . indices . length = 0 ;
475
- meshInfo . uvs . length = 0 ;
476
- meshInfo . colors . length = 0 ;
477
- break ;
462
+ if ( ! this . _multiPassEnabled || this . _meshInfo [ i ] . renderPass == RenderPass . TEXT ) {
463
+ meshInfo . positions . length = meshInfo . normals . length = l * 3 * 4 ;
464
+ meshInfo . indices . length = l * 3 * 2 ;
465
+ meshInfo . uvs . length = l * 2 * 4 ;
466
+ meshInfo . colors . length = l * 4 * 4 ;
467
+ } else {
468
+ meshInfo . positions . length = meshInfo . normals . length = 0 ;
469
+ meshInfo . indices . length = 0 ;
470
+ meshInfo . uvs . length = 0 ;
471
+ meshInfo . colors . length = 0 ;
478
472
}
479
473
480
474
// destroy old mesh
@@ -491,48 +485,44 @@ Object.assign(pc, function () {
491
485
492
486
var mesh = null ;
493
487
494
- switch ( this . _meshInfo [ i ] . renderPass ) {
495
- case RenderPass . TEXT :
496
- case RenderPass . ALL_IN_ONE :
497
- // set up indices and normals whose values don't change when we call _updateMeshes
498
- for ( var v = 0 ; v < l ; v ++ ) {
499
- // create index and normal arrays since they don't change
500
- // if the length doesn't change
501
- meshInfo . indices [ v * 3 * 2 + 0 ] = v * 4 ;
502
- meshInfo . indices [ v * 3 * 2 + 1 ] = v * 4 + 1 ;
503
- meshInfo . indices [ v * 3 * 2 + 2 ] = v * 4 + 3 ;
504
- meshInfo . indices [ v * 3 * 2 + 3 ] = v * 4 + 2 ;
505
- meshInfo . indices [ v * 3 * 2 + 4 ] = v * 4 + 3 ;
506
- meshInfo . indices [ v * 3 * 2 + 5 ] = v * 4 + 1 ;
507
-
508
- meshInfo . normals [ v * 4 * 3 + 0 ] = 0 ;
509
- meshInfo . normals [ v * 4 * 3 + 1 ] = 0 ;
510
- meshInfo . normals [ v * 4 * 3 + 2 ] = - 1 ;
511
-
512
- meshInfo . normals [ v * 4 * 3 + 3 ] = 0 ;
513
- meshInfo . normals [ v * 4 * 3 + 4 ] = 0 ;
514
- meshInfo . normals [ v * 4 * 3 + 5 ] = - 1 ;
515
-
516
- meshInfo . normals [ v * 4 * 3 + 6 ] = 0 ;
517
- meshInfo . normals [ v * 4 * 3 + 7 ] = 0 ;
518
- meshInfo . normals [ v * 4 * 3 + 8 ] = - 1 ;
519
-
520
- meshInfo . normals [ v * 4 * 3 + 9 ] = 0 ;
521
- meshInfo . normals [ v * 4 * 3 + 10 ] = 0 ;
522
- meshInfo . normals [ v * 4 * 3 + 11 ] = - 1 ;
523
- }
524
- mesh = pc . createMesh ( this . _system . app . graphicsDevice ,
525
- meshInfo . positions ,
526
- {
527
- uvs : meshInfo . uvs ,
528
- normals : meshInfo . normals ,
529
- colors : meshInfo . colors ,
530
- indices : meshInfo . indices
531
- } ) ;
532
- break ;
533
- default :
534
- mesh = this . _model . meshInstances [ ti ] . mesh ;
535
- break ;
488
+ if ( ! this . _multiPassEnabled || this . _meshInfo [ i ] . renderPass == RenderPass . TEXT ) {
489
+ // set up indices and normals whose values don't change when we call _updateMeshes
490
+ for ( var v = 0 ; v < l ; v ++ ) {
491
+ // create index and normal arrays since they don't change
492
+ // if the length doesn't change
493
+ meshInfo . indices [ v * 3 * 2 + 0 ] = v * 4 ;
494
+ meshInfo . indices [ v * 3 * 2 + 1 ] = v * 4 + 1 ;
495
+ meshInfo . indices [ v * 3 * 2 + 2 ] = v * 4 + 3 ;
496
+ meshInfo . indices [ v * 3 * 2 + 3 ] = v * 4 + 2 ;
497
+ meshInfo . indices [ v * 3 * 2 + 4 ] = v * 4 + 3 ;
498
+ meshInfo . indices [ v * 3 * 2 + 5 ] = v * 4 + 1 ;
499
+
500
+ meshInfo . normals [ v * 4 * 3 + 0 ] = 0 ;
501
+ meshInfo . normals [ v * 4 * 3 + 1 ] = 0 ;
502
+ meshInfo . normals [ v * 4 * 3 + 2 ] = - 1 ;
503
+
504
+ meshInfo . normals [ v * 4 * 3 + 3 ] = 0 ;
505
+ meshInfo . normals [ v * 4 * 3 + 4 ] = 0 ;
506
+ meshInfo . normals [ v * 4 * 3 + 5 ] = - 1 ;
507
+
508
+ meshInfo . normals [ v * 4 * 3 + 6 ] = 0 ;
509
+ meshInfo . normals [ v * 4 * 3 + 7 ] = 0 ;
510
+ meshInfo . normals [ v * 4 * 3 + 8 ] = - 1 ;
511
+
512
+ meshInfo . normals [ v * 4 * 3 + 9 ] = 0 ;
513
+ meshInfo . normals [ v * 4 * 3 + 10 ] = 0 ;
514
+ meshInfo . normals [ v * 4 * 3 + 11 ] = - 1 ;
515
+ }
516
+ mesh = pc . createMesh ( this . _system . app . graphicsDevice ,
517
+ meshInfo . positions ,
518
+ {
519
+ uvs : meshInfo . uvs ,
520
+ normals : meshInfo . normals ,
521
+ colors : meshInfo . colors ,
522
+ indices : meshInfo . indices
523
+ } ) ;
524
+ } else {
525
+ mesh = this . _model . meshInstances [ ti ] . mesh ;
536
526
}
537
527
538
528
var mi = new pc . MeshInstance ( this . _node , mesh , this . _material ) ;
@@ -565,6 +555,7 @@ Object.assign(pc, function () {
565
555
this . _colorUniform [ 2 ] = this . _color . b ;
566
556
}
567
557
mi . setParameter ( "material_emissive" , this . _colorUniform ) ;
558
+ mi . setParameter ( "material_opacity" , this . _color . a ) ;
568
559
mi . setParameter ( "font_sdfIntensity" , this . _font . intensity ) ;
569
560
mi . setParameter ( "font_pxrange" , this . _getPxRange ( this . _font ) ) ;
570
561
mi . setParameter ( "font_textureWidth" , this . _font . data . info . maps [ ti ] . width ) ;
@@ -573,30 +564,22 @@ Object.assign(pc, function () {
573
564
this . _outlineColorUniform [ 1 ] = this . _outlineColor . g ;
574
565
this . _outlineColorUniform [ 2 ] = this . _outlineColor . b ;
575
566
this . _outlineColorUniform [ 3 ] = this . _outlineColor . a ;
576
-
567
+ mi . setParameter ( "outline_color" , this . _outlineColorUniform ) ;
577
568
mi . setParameter ( "outline_thickness" , this . _outlineThicknessScale * this . _outlineThickness ) ;
578
569
579
570
this . _shadowColorUniform [ 0 ] = this . _shadowColor . r ;
580
571
this . _shadowColorUniform [ 1 ] = this . _shadowColor . g ;
581
572
this . _shadowColorUniform [ 2 ] = this . _shadowColor . b ;
582
573
this . _shadowColorUniform [ 3 ] = this . _shadowColor . a ;
574
+ mi . setParameter ( "shadow_color" , this . _shadowColorUniform ) ;
583
575
584
576
var ratio = this . _font . data . info . maps [ ti ] . width / this . _font . data . info . maps [ ti ] . height ;
585
577
this . _shadowOffsetUniform [ 0 ] = this . _shadowOffsetScale * this . _shadowOffset . x ;
586
578
this . _shadowOffsetUniform [ 1 ] = ratio * this . _shadowOffsetScale * this . _shadowOffset . y ;
587
579
mi . setParameter ( "shadow_offset" , this . _shadowOffsetUniform ) ;
588
580
589
- this . _zeroColorUniform [ 0 ] = 0.0 ;
590
- this . _zeroColorUniform [ 1 ] = 0.0 ;
591
- this . _zeroColorUniform [ 2 ] = 0.0 ;
592
- this . _zeroColorUniform [ 3 ] = 0.0 ;
593
-
594
581
mi . setParameter ( "render_pass" , this . _meshInfo [ i ] . renderPass ) ;
595
582
596
- mi . setParameter ( "material_opacity" , this . _color . a ) ;
597
- mi . setParameter ( "outline_color" , this . _outlineColorUniform ) ;
598
- mi . setParameter ( "shadow_color" , this . _shadowColorUniform ) ;
599
-
600
583
meshInfo . meshInstance = mi ;
601
584
602
585
this . _model . meshInstances . push ( mi ) ;
@@ -1393,15 +1376,17 @@ Object.assign(pc, function () {
1393
1376
1394
1377
var i , len ;
1395
1378
1396
- for ( i = 0 , len = ( this . _multiPassEnabled ) ? 1 : this . _meshInfo . length ; i < len ; i ++ ) {
1397
- var start = startChars [ i ] || 0 ;
1398
- var end = endChars [ i ] || 0 ;
1399
- var instance = this . _meshInfo [ i ] . meshInstance ;
1400
- if ( instance ) {
1401
- var mesh = instance . mesh ;
1402
- if ( mesh ) {
1403
- mesh . primitive [ 0 ] . base = start * 3 * 2 ;
1404
- mesh . primitive [ 0 ] . count = ( end - start ) * 3 * 2 ;
1379
+ for ( i = 0 , len = this . _meshInfo . length ; i < len ; i ++ ) {
1380
+ if ( ! this . _multiPassEnabled || this . _meshInfo [ i ] . renderPass == RenderPass . TEXT ) {
1381
+ var start = startChars [ i ] || 0 ;
1382
+ var end = endChars [ i ] || 0 ;
1383
+ var instance = this . _meshInfo [ i ] . meshInstance ;
1384
+ if ( instance ) {
1385
+ var mesh = instance . mesh ;
1386
+ if ( mesh ) {
1387
+ mesh . primitive [ 0 ] . base = start * 3 * 2 ;
1388
+ mesh . primitive [ 0 ] . count = ( end - start ) * 3 * 2 ;
1389
+ }
1405
1390
}
1406
1391
}
1407
1392
}
@@ -1492,9 +1477,9 @@ Object.assign(pc, function () {
1492
1477
this . _color . a = value ;
1493
1478
1494
1479
if ( this . _model ) {
1495
- for ( var i = 0 ; i < this . _model . meshInstances . length ; i ++ ) {
1480
+ for ( var i = 0 , len = this . _model . meshInstances . length ; i < len ; i ++ ) {
1496
1481
var mi = this . _model . meshInstances [ i ] ;
1497
- mi . setParameter ( " material_opacity" , this . _color . a ) ;
1482
+ mi . setParameter ( ' material_opacity' , value ) ;
1498
1483
}
1499
1484
}
1500
1485
}
@@ -1799,7 +1784,7 @@ Object.assign(pc, function () {
1799
1784
1800
1785
if ( opaquenessChanged ) this . _updateText ( ) ;
1801
1786
1802
- for ( var i = 0 ; i < this . _model . meshInstances . length ; i ++ ) {
1787
+ for ( var i = 0 , len = this . _model . meshInstances . length ; i < len ; i ++ ) {
1803
1788
var mi = this . _model . meshInstances [ i ] ;
1804
1789
mi . setParameter ( "outline_color" , this . _outlineColorUniform ) ;
1805
1790
}
@@ -1822,7 +1807,7 @@ Object.assign(pc, function () {
1822
1807
1823
1808
for ( var i = 0 , len = this . _model . meshInstances . length ; i < len ; i ++ ) {
1824
1809
var mi = this . _model . meshInstances [ i ] ;
1825
- mi . setParameter ( "outline_thickness" , this . _outlineThicknessScale * Math . min ( this . _outlineThickness , ( this . _font . data . version == 3 ) ? 1 .0 : 5 .0) ) ;
1810
+ mi . setParameter ( "outline_thickness" , this . _outlineThicknessScale * Math . min ( this . _outlineThickness , ( this . _font . data . version >= 4 ) ? 5 .0 : 1 .0) ) ;
1826
1811
}
1827
1812
}
1828
1813
}
0 commit comments