@@ -360,6 +360,68 @@ Object.assign(pc, function () {
360
360
return sub ;
361
361
}
362
362
363
+ // Test for IE11
364
+ var quantizeCache = new Map ( ) ;
365
+ var quantizeSetCache = new Map ( ) ;
366
+ var quantizeSetClamp01Cache = new Map ( ) ;
367
+ var divGraphCache = new Map ( ) ;
368
+ var divMaxCache = new Map ( ) ;
369
+
370
+ function getQuantizeFromCache ( graph , precision ) {
371
+ var hash = pc . hashCurve ( graph ) ;
372
+ var outGraph = quantizeCache . get ( hash ) ;
373
+ if ( ! outGraph ) {
374
+ outGraph = graph . quantize ( precision ) ;
375
+ quantizeCache . set ( hash , outGraph ) ;
376
+ }
377
+
378
+ return outGraph ;
379
+ }
380
+
381
+ function getQuantizeSetFromCache ( graph , precision ) {
382
+ var hash = pc . hashCurveSet ( graph ) ;
383
+ var outGraph = quantizeSetCache . get ( hash ) ;
384
+ if ( ! outGraph ) {
385
+ outGraph = graph . quantize ( precision ) ;
386
+ quantizeSetCache . set ( hash , outGraph ) ;
387
+ }
388
+
389
+ return outGraph ;
390
+ }
391
+
392
+ function getQuantizeSetClamp01FromCache ( graph , precision ) {
393
+ var hash = pc . hashCurveSet ( graph ) ;
394
+ var outGraph = quantizeSetClamp01Cache . get ( hash ) ;
395
+ if ( ! outGraph ) {
396
+ outGraph = graph . quantizeClamped ( precision , 0 , 1 ) ;
397
+ quantizeSetClamp01Cache . set ( hash , outGraph ) ;
398
+ }
399
+
400
+ return outGraph ;
401
+ }
402
+
403
+ function getDivGraphFromCache ( graph1 , graph2 , outMax ) {
404
+ var hash = pc . hash2Float32Arrays ( graph1 , graph2 ) ;
405
+ var divGraph = divGraphCache . get ( hash ) ;
406
+ var divMax ;
407
+ if ( divGraph ) {
408
+ divMax = divMaxCache . get ( hash ) ;
409
+
410
+ } else {
411
+ divMax = new Float32Array ( outMax . length ) ;
412
+ divGraph = divGraphFrom2Curves ( graph1 , graph2 , divMax ) ;
413
+ divGraphCache . set ( hash , divGraph ) ;
414
+ divMaxCache . set ( hash , divMax ) ;
415
+ }
416
+
417
+ for ( var i = 0 ; i < divMax . length ; ++ i ) {
418
+ outMax [ i ] = divMax [ i ] ;
419
+ }
420
+
421
+ return divGraph ;
422
+ }
423
+
424
+
363
425
Object . assign ( ParticleEmitter . prototype , {
364
426
365
427
onChangeCamera : function ( ) {
@@ -689,22 +751,22 @@ Object.assign(pc, function () {
689
751
var precision = this . precision ;
690
752
var gd = this . graphicsDevice ;
691
753
var i ;
692
-
693
- this . qLocalVelocity = this . localVelocityGraph . quantize ( precision ) ;
694
- this . qVelocity = this . velocityGraph . quantize ( precision ) ;
695
- this . qColor = this . colorGraph . quantizeClamped ( precision , 0 , 1 ) ;
696
- this . qRotSpeed = this . rotationSpeedGraph . quantize ( precision ) ;
697
- this . qScale = this . scaleGraph . quantize ( precision ) ;
698
- this . qAlpha = this . alphaGraph . quantize ( precision ) ;
699
- this . qRadialSpeed = this . radialSpeedGraph . quantize ( precision ) ;
700
-
701
- this . qLocalVelocity2 = this . localVelocityGraph2 . quantize ( precision ) ;
702
- this . qVelocity2 = this . velocityGraph2 . quantize ( precision ) ;
703
- this . qColor2 = this . colorGraph2 . quantizeClamped ( precision , 0 , 1 ) ;
704
- this . qRotSpeed2 = this . rotationSpeedGraph2 . quantize ( precision ) ;
705
- this . qScale2 = this . scaleGraph2 . quantize ( precision ) ;
706
- this . qAlpha2 = this . alphaGraph2 . quantize ( precision ) ;
707
- this . qRadialSpeed2 = this . radialSpeedGraph2 . quantize ( precision ) ;
754
+
755
+ this . qLocalVelocity = getQuantizeSetFromCache ( this . localVelocityGraph , precision ) ;
756
+ this . qVelocity = getQuantizeSetFromCache ( this . velocityGraph , precision ) ;
757
+ this . qColor = getQuantizeSetClamp01FromCache ( this . colorGraph , precision ) ;
758
+ this . qRotSpeed = getQuantizeFromCache ( this . rotationSpeedGraph , precision ) ;
759
+ this . qScale = getQuantizeFromCache ( this . scaleGraph , precision ) ;
760
+ this . qAlpha = getQuantizeFromCache ( this . alphaGraph , precision ) ;
761
+ this . qRadialSpeed = getQuantizeFromCache ( this . radialSpeedGraph , precision ) ;
762
+
763
+ this . qLocalVelocity2 = getQuantizeSetFromCache ( this . localVelocityGraph2 , precision ) ;
764
+ this . qVelocity2 = getQuantizeSetFromCache ( this . velocityGraph2 , precision ) ;
765
+ this . qColor2 = getQuantizeSetClamp01FromCache ( this . colorGraph2 , precision ) ;
766
+ this . qRotSpeed2 = getQuantizeFromCache ( this . rotationSpeedGraph2 , precision ) ;
767
+ this . qScale2 = getQuantizeFromCache ( this . scaleGraph2 , precision ) ;
768
+ this . qAlpha2 = getQuantizeFromCache ( this . alphaGraph2 , precision ) ;
769
+ this . qRadialSpeed2 = getQuantizeFromCache ( this . radialSpeedGraph2 , precision ) ;
708
770
709
771
for ( i = 0 ; i < precision ; i ++ ) {
710
772
this . qRotSpeed [ i ] *= pc . math . DEG_TO_RAD ;
@@ -718,13 +780,22 @@ Object.assign(pc, function () {
718
780
this . scaleUMax = [ 0 ] ;
719
781
this . alphaUMax = [ 0 ] ;
720
782
this . radialSpeedUMax = [ 0 ] ;
721
- this . qLocalVelocityDiv = divGraphFrom2Curves ( this . qLocalVelocity , this . qLocalVelocity2 , this . localVelocityUMax ) ;
722
- this . qVelocityDiv = divGraphFrom2Curves ( this . qVelocity , this . qVelocity2 , this . velocityUMax ) ;
723
- this . qColorDiv = divGraphFrom2Curves ( this . qColor , this . qColor2 , this . colorUMax ) ;
724
- this . qRotSpeedDiv = divGraphFrom2Curves ( this . qRotSpeed , this . qRotSpeed2 , this . rotSpeedUMax ) ;
725
- this . qScaleDiv = divGraphFrom2Curves ( this . qScale , this . qScale2 , this . scaleUMax ) ;
726
- this . qAlphaDiv = divGraphFrom2Curves ( this . qAlpha , this . qAlpha2 , this . alphaUMax ) ;
727
- this . qRadialSpeedDiv = divGraphFrom2Curves ( this . qRadialSpeed , this . qRadialSpeed2 , this . radialSpeedUMax ) ;
783
+
784
+ this . qLocalVelocityDiv = getDivGraphFromCache ( this . qLocalVelocity , this . qLocalVelocity2 , this . localVelocityUMax ) ;
785
+ this . qVelocityDiv = getDivGraphFromCache ( this . qVelocity , this . qVelocity2 , this . velocityUMax ) ;
786
+ this . qColorDiv = getDivGraphFromCache ( this . qColor , this . qColor2 , this . colorUMax ) ;
787
+ this . qRotSpeedDiv = getDivGraphFromCache ( this . qRotSpeed , this . qRotSpeed2 , this . rotSpeedUMax ) ;
788
+ this . qScaleDiv = getDivGraphFromCache ( this . qScale , this . qScale2 , this . scaleUMax ) ;
789
+ this . qAlphaDiv = getDivGraphFromCache ( this . qAlpha , this . qAlpha2 , this . alphaUMax ) ;
790
+ this . qRadialSpeedDiv = getDivGraphFromCache ( this . qRadialSpeed , this . qRadialSpeed2 , this . radialSpeedUMax ) ;
791
+
792
+ // this.qLocalVelocityDiv = divGraphFrom2Curves(this.qLocalVelocity, this.qLocalVelocity2, this.localVelocityUMax);
793
+ // this.qVelocityDiv = divGraphFrom2Curves(this.qVelocity, this.qVelocity2, this.velocityUMax);
794
+ // this.qColorDiv = divGraphFrom2Curves(this.qColor, this.qColor2, this.colorUMax);
795
+ // this.qRotSpeedDiv = divGraphFrom2Curves(this.qRotSpeed, this.qRotSpeed2, this.rotSpeedUMax);
796
+ // this.qScaleDiv = divGraphFrom2Curves(this.qScale, this.qScale2, this.scaleUMax);
797
+ // this.qAlphaDiv = divGraphFrom2Curves(this.qAlpha, this.qAlpha2, this.alphaUMax);
798
+ // this.qRadialSpeedDiv = divGraphFrom2Curves(this.qRadialSpeed, this.qRadialSpeed2, this.radialSpeedUMax);
728
799
729
800
if ( this . pack8 ) {
730
801
var umax = [ 0 , 0 , 0 ] ;
0 commit comments