-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathdeprecated.js
887 lines (748 loc) · 33.4 KB
/
deprecated.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
import { Debug } from '../core/debug.js';
import { Vec2 } from '../core/math/vec2.js';
import { Vec3 } from '../core/math/vec3.js';
import { Vec4 } from '../core/math/vec4.js';
import {
BLENDMODE_CONSTANT, BLENDMODE_ONE_MINUS_CONSTANT,
PIXELFORMAT_LA8, PIXELFORMAT_RGB565, PIXELFORMAT_RGBA5551, PIXELFORMAT_RGBA4, PIXELFORMAT_RGB8, PIXELFORMAT_RGBA8,
PIXELFORMAT_SRGB8, PIXELFORMAT_SRGBA8,
TEXTURETYPE_DEFAULT, TEXTURETYPE_RGBM, TEXTURETYPE_SWIZZLEGGGR
} from '../platform/graphics/constants.js';
import { drawQuadWithShader } from '../scene/graphics/quad-render-utils.js';
import { shaderChunks } from '../scene/shader-lib/chunks/chunks.js';
import { GraphicsDevice } from '../platform/graphics/graphics-device.js';
import { LayerComposition } from '../scene/composition/layer-composition.js';
import { RenderTarget } from '../platform/graphics/render-target.js';
import { Texture } from '../platform/graphics/texture.js';
import { VertexFormat } from '../platform/graphics/vertex-format.js';
import { BlendState } from '../platform/graphics/blend-state.js';
import { DepthState } from '../platform/graphics/depth-state.js';
import { CylinderGeometry } from '../scene/geometry/cylinder-geometry.js';
import { BoxGeometry } from '../scene/geometry/box-geometry.js';
import { CapsuleGeometry } from '../scene/geometry/capsule-geometry.js';
import { ConeGeometry } from '../scene/geometry/cone-geometry.js';
import { PlaneGeometry } from '../scene/geometry/plane-geometry.js';
import { SphereGeometry } from '../scene/geometry/sphere-geometry.js';
import { TorusGeometry } from '../scene/geometry/torus-geometry.js';
import { ForwardRenderer } from '../scene/renderer/forward-renderer.js';
import { GraphNode } from '../scene/graph-node.js';
import { Material } from '../scene/materials/material.js';
import { Mesh } from '../scene/mesh.js';
import { Morph } from '../scene/morph.js';
import { MeshInstance } from '../scene/mesh-instance.js';
import { Scene } from '../scene/scene.js';
import { StandardMaterial } from '../scene/materials/standard-material.js';
import { getDefaultMaterial } from '../scene/materials/default-material.js';
import { StandardMaterialOptions } from '../scene/materials/standard-material-options.js';
import { LitShaderOptions } from '../scene/shader-lib/programs/lit-shader-options.js';
import { Layer } from '../scene/layer.js';
import { AssetRegistry } from '../framework/asset/asset-registry.js';
import { XrInputSource } from '../framework/xr/xr-input-source.js';
import { ElementInput } from '../framework/input/element-input.js';
import { MouseEvent } from '../platform/input/mouse-event.js';
import { AppBase } from '../framework/app-base.js';
import { getApplication } from '../framework/globals.js';
import { ModelComponent } from '../framework/components/model/component.js';
import {
BODYFLAG_KINEMATIC_OBJECT, BODYFLAG_NORESPONSE_OBJECT, BODYFLAG_STATIC_OBJECT,
BODYSTATE_ACTIVE_TAG, BODYSTATE_DISABLE_DEACTIVATION, BODYSTATE_DISABLE_SIMULATION, BODYSTATE_ISLAND_SLEEPING, BODYSTATE_WANTS_DEACTIVATION,
BODYTYPE_DYNAMIC, BODYTYPE_KINEMATIC, BODYTYPE_STATIC
} from '../framework/components/rigid-body/constants.js';
import { RigidBodyComponent } from '../framework/components/rigid-body/component.js';
import { RigidBodyComponentSystem } from '../framework/components/rigid-body/system.js';
import { Geometry } from '../scene/geometry/geometry.js';
import { CameraComponent } from '../framework/components/camera/component.js';
// MATH
Vec2.prototype.scale = Vec2.prototype.mulScalar;
Vec3.prototype.scale = Vec3.prototype.mulScalar;
Vec4.prototype.scale = Vec4.prototype.mulScalar;
// GRAPHICS
export const PIXELFORMAT_L8_A8 = PIXELFORMAT_LA8;
export const PIXELFORMAT_R5_G6_B5 = PIXELFORMAT_RGB565;
export const PIXELFORMAT_R5_G5_B5_A1 = PIXELFORMAT_RGBA5551;
export const PIXELFORMAT_R4_G4_B4_A4 = PIXELFORMAT_RGBA4;
export const PIXELFORMAT_R8_G8_B8 = PIXELFORMAT_RGB8;
export const PIXELFORMAT_R8_G8_B8_A8 = PIXELFORMAT_RGBA8;
export const PIXELFORMAT_SRGB = PIXELFORMAT_SRGB8;
export const PIXELFORMAT_SRGBA = PIXELFORMAT_SRGBA8;
export const BLENDMODE_CONSTANT_COLOR = BLENDMODE_CONSTANT;
export const BLENDMODE_ONE_MINUS_CONSTANT_COLOR = BLENDMODE_ONE_MINUS_CONSTANT;
export const BLENDMODE_CONSTANT_ALPHA = BLENDMODE_CONSTANT;
export const BLENDMODE_ONE_MINUS_CONSTANT_ALPHA = BLENDMODE_ONE_MINUS_CONSTANT;
const _viewport = new Vec4();
export function createSphere(device, opts) {
Debug.deprecated('pc.createSphere is deprecated. Use \'pc.Mesh.fromGeometry(device, new SphereGeometry(options);\' format instead.');
return Mesh.fromGeometry(device, new SphereGeometry(opts));
}
export function createPlane(device, opts) {
Debug.deprecated('pc.createPlane is deprecated. Use \'pc.Mesh.fromGeometry(device, new PlaneGeometry(options);\' format instead.');
return Mesh.fromGeometry(device, new PlaneGeometry(opts));
}
export function createBox(device, opts) {
Debug.deprecated('pc.createBox is deprecated. Use \'pc.Mesh.fromGeometry(device, new BoxGeometry(options);\' format instead.');
return Mesh.fromGeometry(device, new BoxGeometry(opts));
}
export function createTorus(device, opts) {
Debug.deprecated('pc.createTorus is deprecated. Use \'pc.Mesh.fromGeometry(device, new TorusGeometry(options);\' format instead.');
return Mesh.fromGeometry(device, new TorusGeometry(opts));
}
export function createCapsule(device, opts) {
Debug.deprecated('pc.createCapsule is deprecated. Use \'pc.Mesh.fromGeometry(device, new CapsuleGeometry(options);\' format instead.');
return Mesh.fromGeometry(device, new CapsuleGeometry(opts));
}
export function createCone(device, opts) {
Debug.deprecated('pc.createCone is deprecated. Use \'pc.Mesh.fromGeometry(device, new ConeGeometry(options);\' format instead.');
return Mesh.fromGeometry(device, new ConeGeometry(opts));
}
export function createCylinder(device, opts) {
Debug.deprecated('pc.createCylinder is deprecated. Use \'pc.Mesh.fromGeometry(device, new CylinderGeometry(options);\' format instead.');
return Mesh.fromGeometry(device, new CylinderGeometry(opts));
}
export function createMesh(device, positions, opts = {}) {
Debug.deprecated('pc.createMesh is deprecated. Use \'pc.Mesh.fromGeometry(device, new Geometry();\' format instead.');
const geom = new Geometry();
geom.positions = positions;
geom.normals = opts.normals;
geom.tangents = opts.tangents;
geom.colors = opts.colors;
geom.uvs = opts.uvs;
geom.uvs1 = opts.uvs1;
geom.blendIndices = opts.blendIndices;
geom.blendWeights = opts.blendWeights;
geom.indices = opts.indices;
return Mesh.fromGeometry(device, geom, opts);
}
export function drawFullscreenQuad(device, target, vertexBuffer, shader, rect) {
Debug.deprecated('pc.drawFullscreenQuad is deprecated. When used as part of PostEffect, use PostEffect#drawQuad instead.');
// convert rect in normalized space to viewport in pixel space
let viewport;
if (rect) {
const w = target ? target.width : device.width;
const h = target ? target.height : device.height;
viewport = _viewport.set(rect.x * w, rect.y * h, rect.z * w, rect.w * h);
}
drawQuadWithShader(device, target, shader, viewport);
}
const deprecatedChunks = {
'ambientPrefilteredCube.frag': 'ambientEnv.frag',
'ambientPrefilteredCubeLod.frag': 'ambientEnv.frag',
'dpAtlasQuad.frag': null,
'genParaboloid.frag': null,
'prefilterCubemap.frag': null,
'reflectionDpAtlas.frag': 'reflectionEnv.frag',
'reflectionPrefilteredCube.frag': 'reflectionEnv.frag',
'reflectionPrefilteredCubeLod.frag': 'reflectionEnv.frag'
};
Object.keys(deprecatedChunks).forEach((chunkName) => {
const replacement = deprecatedChunks[chunkName];
const useInstead = replacement ? ` Use pc.shaderChunks['${replacement}'] instead.` : '';
const msg = `pc.shaderChunks['${chunkName}'] is deprecated.${useInstead}}`;
Object.defineProperty(shaderChunks, chunkName, {
get: function () {
Debug.error(msg);
return null;
},
set: function () {
Debug.error(msg);
}
});
});
// Note: This was never public interface, but has been used in external scripts
Object.defineProperties(RenderTarget.prototype, {
_glFrameBuffer: {
get: function () {
Debug.deprecated('pc.RenderTarget#_glFrameBuffer is deprecated. Use pc.RenderTarget.impl#_glFrameBuffer instead.');
return this.impl._glFrameBuffer;
},
set: function (rgbm) {
Debug.deprecated('pc.RenderTarget#_glFrameBuffer is deprecated. Use pc.RenderTarget.impl#_glFrameBuffer instead.');
}
}
});
Object.defineProperty(VertexFormat, 'defaultInstancingFormat', {
get: function () {
Debug.assert('pc.VertexFormat.defaultInstancingFormat is deprecated, use pc.VertexFormat.getDefaultInstancingFormat(graphicsDevice).');
return null;
}
});
Object.defineProperties(Texture.prototype, {
rgbm: {
get: function () {
Debug.deprecated('pc.Texture#rgbm is deprecated. Use pc.Texture#type instead.');
return this.type === TEXTURETYPE_RGBM;
},
set: function (rgbm) {
Debug.deprecated('pc.Texture#rgbm is deprecated. Use pc.Texture#type instead.');
this.type = rgbm ? TEXTURETYPE_RGBM : TEXTURETYPE_DEFAULT;
}
},
swizzleGGGR: {
get: function () {
Debug.deprecated('pc.Texture#swizzleGGGR is deprecated. Use pc.Texture#type instead.');
return this.type === TEXTURETYPE_SWIZZLEGGGR;
},
set: function (swizzleGGGR) {
Debug.deprecated('pc.Texture#swizzleGGGR is deprecated. Use pc.Texture#type instead.');
this.type = swizzleGGGR ? TEXTURETYPE_SWIZZLEGGGR : TEXTURETYPE_DEFAULT;
}
},
_glTexture: {
get: function () {
Debug.deprecated('pc.Texture#_glTexture is no longer available, use Use pc.Texture.impl._glTexture instead.');
return this.impl._glTexture;
}
}
});
Object.defineProperty(GraphicsDevice.prototype, 'boneLimit', {
get: function () {
Debug.deprecated('pc.GraphicsDevice#boneLimit is deprecated and the limit has been removed.');
return 1024;
}
});
Object.defineProperty(GraphicsDevice.prototype, 'webgl2', {
get: function () {
Debug.deprecated('pc.GraphicsDevice#webgl2 is deprecated, use pc.GraphicsDevice#isWebGL2 instead.');
return this.isWebGL2;
}
});
Object.defineProperty(GraphicsDevice.prototype, 'textureFloatHighPrecision', {
get: function () {
Debug.deprecated('pc.GraphicsDevice#textureFloatHighPrecision is deprecated and always returns true.');
return true;
}
});
Object.defineProperty(GraphicsDevice.prototype, 'extBlendMinmax', {
get: function () {
Debug.deprecated('pc.GraphicsDevice#extBlendMinmax is deprecated as it is always true.');
return true;
}
});
Object.defineProperty(GraphicsDevice.prototype, 'extTextureHalfFloat', {
get: function () {
Debug.deprecated('pc.GraphicsDevice#extTextureHalfFloat is deprecated as it is always true.');
return true;
}
});
Object.defineProperty(GraphicsDevice.prototype, 'extTextureLod', {
get: function () {
Debug.deprecated('pc.GraphicsDevice#extTextureLod is deprecated as it is always true.');
return true;
}
});
Object.defineProperty(GraphicsDevice.prototype, 'textureHalfFloatFilterable', {
get: function () {
Debug.deprecated('pc.GraphicsDevice#textureHalfFloatFilterable is deprecated as it is always true.');
return true;
}
});
Object.defineProperty(GraphicsDevice.prototype, 'supportsMrt', {
get: function () {
Debug.deprecated('pc.GraphicsDevice#supportsMrt is deprecated as it is always true.');
return true;
}
});
Object.defineProperty(GraphicsDevice.prototype, 'supportsVolumeTextures', {
get: function () {
Debug.deprecated('pc.GraphicsDevice#supportsVolumeTextures is deprecated as it is always true.');
return true;
}
});
Object.defineProperty(GraphicsDevice.prototype, 'supportsInstancing', {
get: function () {
Debug.deprecated('pc.GraphicsDevice#supportsInstancing is deprecated as it is always true.');
return true;
}
});
Object.defineProperty(GraphicsDevice.prototype, 'textureHalfFloatUpdatable', {
get: function () {
Debug.deprecated('pc.GraphicsDevice#textureHalfFloatUpdatable is deprecated as it is always true.');
return true;
}
});
Object.defineProperty(GraphicsDevice.prototype, 'extTextureFloat', {
get: function () {
Debug.deprecated('pc.GraphicsDevice#extTextureFloat is deprecated as it is always true');
return true;
}
});
Object.defineProperty(GraphicsDevice.prototype, 'extStandardDerivatives', {
get: function () {
Debug.deprecated('pc.GraphicsDevice#extStandardDerivatives is deprecated as it is always true.');
return true;
}
});
BlendState.DEFAULT = Object.freeze(new BlendState());
const _tempBlendState = new BlendState();
const _tempDepthState = new DepthState();
GraphicsDevice.prototype.setBlendFunction = function (blendSrc, blendDst) {
Debug.deprecated('pc.GraphicsDevice#setBlendFunction is deprecated, use pc.GraphicsDevice.setBlendState instead.');
const currentBlendState = this.blendState;
_tempBlendState.copy(currentBlendState);
_tempBlendState.setColorBlend(currentBlendState.colorOp, blendSrc, blendDst);
_tempBlendState.setAlphaBlend(currentBlendState.alphaOp, blendSrc, blendDst);
this.setBlendState(_tempBlendState);
};
GraphicsDevice.prototype.setBlendFunctionSeparate = function (blendSrc, blendDst, blendSrcAlpha, blendDstAlpha) {
Debug.deprecated('pc.GraphicsDevice#setBlendFunctionSeparate is deprecated, use pc.GraphicsDevice.setBlendState instead.');
const currentBlendState = this.blendState;
_tempBlendState.copy(currentBlendState);
_tempBlendState.setColorBlend(currentBlendState.colorOp, blendSrc, blendDst);
_tempBlendState.setAlphaBlend(currentBlendState.alphaOp, blendSrcAlpha, blendDstAlpha);
this.setBlendState(_tempBlendState);
};
GraphicsDevice.prototype.setBlendEquation = function (blendEquation) {
Debug.deprecated('pc.GraphicsDevice#setBlendEquation is deprecated, use pc.GraphicsDevice.setBlendState instead.');
const currentBlendState = this.blendState;
_tempBlendState.copy(currentBlendState);
_tempBlendState.setColorBlend(blendEquation, currentBlendState.colorSrcFactor, currentBlendState.colorDstFactor);
_tempBlendState.setAlphaBlend(blendEquation, currentBlendState.alphaSrcFactor, currentBlendState.alphaDstFactor);
this.setBlendState(_tempBlendState);
};
GraphicsDevice.prototype.setBlendEquationSeparate = function (blendEquation, blendAlphaEquation) {
Debug.deprecated('pc.GraphicsDevice#setBlendEquationSeparate is deprecated, use pc.GraphicsDevice.setBlendState instead.');
const currentBlendState = this.blendState;
_tempBlendState.copy(currentBlendState);
_tempBlendState.setColorBlend(blendEquation, currentBlendState.colorSrcFactor, currentBlendState.colorDstFactor);
_tempBlendState.setAlphaBlend(blendAlphaEquation, currentBlendState.alphaSrcFactor, currentBlendState.alphaDstFactor);
this.setBlendState(_tempBlendState);
};
GraphicsDevice.prototype.setColorWrite = function (redWrite, greenWrite, blueWrite, alphaWrite) {
Debug.deprecated('pc.GraphicsDevice#setColorWrite is deprecated, use pc.GraphicsDevice.setBlendState instead.');
const currentBlendState = this.blendState;
_tempBlendState.copy(currentBlendState);
_tempBlendState.setColorWrite(redWrite, greenWrite, blueWrite, alphaWrite);
this.setBlendState(_tempBlendState);
};
GraphicsDevice.prototype.getBlending = function () {
return this.blendState.blend;
};
GraphicsDevice.prototype.setBlending = function (blending) {
Debug.deprecated('pc.GraphicsDevice#setBlending is deprecated, use pc.GraphicsDevice.setBlendState instead.');
_tempBlendState.copy(this.blendState);
_tempBlendState.blend = blending;
this.setBlendState(_tempBlendState);
};
GraphicsDevice.prototype.setDepthWrite = function (write) {
Debug.deprecated('pc.GraphicsDevice#setDepthWrite is deprecated, use pc.GraphicsDevice.setDepthState instead.');
_tempDepthState.copy(this.depthState);
_tempDepthState.write = write;
this.setDepthState(_tempDepthState);
};
GraphicsDevice.prototype.setDepthFunc = function (func) {
Debug.deprecated('pc.GraphicsDevice#setDepthFunc is deprecated, use pc.GraphicsDevice.setDepthState instead.');
_tempDepthState.copy(this.depthState);
_tempDepthState.func = func;
this.setDepthState(_tempDepthState);
};
GraphicsDevice.prototype.setDepthTest = function (test) {
Debug.deprecated('pc.GraphicsDevice#setDepthTest is deprecated, use pc.GraphicsDevice.setDepthState instead.');
_tempDepthState.copy(this.depthState);
_tempDepthState.test = test;
this.setDepthState(_tempDepthState);
};
GraphicsDevice.prototype.getCullMode = function () {
return this.cullMode;
};
// SCENE
export const LitOptions = LitShaderOptions;
Object.defineProperty(Scene.prototype, 'defaultMaterial', {
get: function () {
Debug.deprecated('pc.Scene#defaultMaterial is deprecated.');
return getDefaultMaterial(getApplication().graphicsDevice);
}
});
Object.defineProperty(Scene.prototype, 'fogColor', {
set: function (value) {
Debug.deprecated('Scene#fogColor is deprecated. Use Scene#fog.color instead.');
this.fog.color = value;
},
get: function () {
Debug.deprecated('Scene#fogColor is deprecated. Use Scene#fog.color instead.');
return this.fog.color;
}
});
Object.defineProperty(Scene.prototype, 'fogEnd', {
set: function (value) {
Debug.deprecated('Scene#fogEnd is deprecated. Use Scene#fog.end instead.');
this.fog.end = value;
},
get: function () {
Debug.deprecated('Scene#fogEnd is deprecated. Use Scene#fog.end instead.');
return this.fog.end;
}
});
Object.defineProperty(Scene.prototype, 'fogStart', {
set: function (value) {
Debug.deprecated('Scene#fogStart is deprecated. Use Scene#fog.start instead.');
this.fog.start = value;
},
get: function () {
Debug.deprecated('Scene#fogStart is deprecated. Use Scene#fog.start instead.');
return this.fog.start;
}
});
Object.defineProperty(Scene.prototype, 'fogDensity', {
set: function (value) {
Debug.deprecated('Scene#fogDensity is deprecated. Use Scene#fog.density instead.');
this.fog.density = value;
},
get: function () {
Debug.deprecated('Scene#fogDensity is deprecated. Use Scene#fog.density instead.');
return this.fog.density;
}
});
Object.defineProperty(Scene.prototype, 'toneMapping', {
set: function (value) {
Debug.removed('Scene#toneMapping is removed. Use CameraComponent#toneMapping instead.');
},
get: function () {
Debug.removed('Scene#toneMapping is removed. Use CameraComponent#toneMapping instead.');
return undefined;
}
});
Object.defineProperty(Scene.prototype, 'gammaCorrection', {
set: function (value) {
Debug.removed('Scene#gammaCorrection is removed. Use CameraComponent#gammaCorrection instead.');
},
get: function () {
Debug.removed('Scene#gammaCorrection is removed. Use CameraComponent#gammaCorrection instead.');
return undefined;
}
});
Object.defineProperty(Scene.prototype, 'rendering', {
set: function (value) {
Debug.removed('Scene#rendering is removed. Use Scene#fog or CameraComponent#gammaCorrection or CameraComponent#toneMapping instead.');
},
get: function () {
Debug.removed('Scene#rendering is removed. Use Scene#fog or CameraComponent#gammaCorrection or CameraComponent#toneMapping instead.');
return undefined;
}
});
Object.defineProperty(LayerComposition.prototype, '_meshInstances', {
get: function () {
Debug.deprecated('pc.LayerComposition#_meshInstances is deprecated.');
return null;
}
});
Object.defineProperty(Scene.prototype, 'drawCalls', {
get: function () {
Debug.deprecated('pc.Scene#drawCalls is deprecated and no longer provides mesh instances.');
return null;
}
});
// scene.skyboxPrefiltered**** are deprecated
['128', '64', '32', '16', '8', '4'].forEach((size, index) => {
Object.defineProperty(Scene.prototype, `skyboxPrefiltered${size}`, {
get: function () {
Debug.deprecated(`pc.Scene#skyboxPrefiltered${size} is deprecated. Use pc.Scene#prefilteredCubemaps instead.`);
return this._prefilteredCubemaps[index];
},
set: function (value) {
Debug.deprecated(`pc.Scene#skyboxPrefiltered${size} is deprecated. Use pc.Scene#prefilteredCubemaps instead.`);
this._prefilteredCubemaps[index] = value;
this.updateShaders = true;
}
});
});
Object.defineProperty(Scene.prototype, 'models', {
get: function () {
if (!this._models) {
this._models = [];
}
return this._models;
}
});
// A helper function to add deprecated set and get property on a class
function _removedClassProperty(targetClass, name, comment = '') {
Object.defineProperty(targetClass.prototype, name, {
set: function (value) {
Debug.errorOnce(`${targetClass.name}#${name} has been removed. ${comment}`);
},
get: function () {
Debug.errorOnce(`${targetClass.name}#${name} has been removed. ${comment}`);
return undefined;
}
});
}
_removedClassProperty(Layer, 'renderTarget');
_removedClassProperty(Layer, 'onPreCull');
_removedClassProperty(Layer, 'onPreRender');
_removedClassProperty(Layer, 'onPreRenderOpaque');
_removedClassProperty(Layer, 'onPreRenderTransparent');
_removedClassProperty(Layer, 'onPostCull');
_removedClassProperty(Layer, 'onPostRender');
_removedClassProperty(Layer, 'onPostRenderOpaque');
_removedClassProperty(Layer, 'onPostRenderTransparent');
_removedClassProperty(Layer, 'onDrawCall');
_removedClassProperty(Layer, 'layerReference');
_removedClassProperty(CameraComponent, 'onPreCull', 'Use Scene#EVENT_PRECULL event instead.');
_removedClassProperty(CameraComponent, 'onPostCull', 'Use Scene#EVENT_POSTCULL event instead.');
_removedClassProperty(CameraComponent, 'onPreRender', 'Use Scene#EVENT_PRERENDER event instead.');
_removedClassProperty(CameraComponent, 'onPostRender', 'Use Scene#EVENT_POSTRENDER event instead.');
_removedClassProperty(CameraComponent, 'onPreRenderLayer', 'Use Scene#EVENT_PRERENDER_LAYER event instead.');
_removedClassProperty(CameraComponent, 'onPostRenderLayer', 'Use Scene#EVENT_POSTRENDER_LAYER event instead.');
ForwardRenderer.prototype.renderComposition = function (comp) {
Debug.deprecated('pc.ForwardRenderer#renderComposition is deprecated. Use pc.AppBase.renderComposition instead.');
getApplication().renderComposition(comp);
};
MeshInstance.prototype.syncAabb = function () {
Debug.deprecated('pc.MeshInstance#syncAabb is deprecated.');
};
Morph.prototype.getTarget = function (index) {
Debug.deprecated('pc.Morph#getTarget is deprecated. Use pc.Morph#targets instead.');
return this.targets[index];
};
GraphNode.prototype.getChildren = function () {
Debug.deprecated('pc.GraphNode#getChildren is deprecated. Use pc.GraphNode#children instead.');
return this.children;
};
GraphNode.prototype.getName = function () {
Debug.deprecated('pc.GraphNode#getName is deprecated. Use pc.GraphNode#name instead.');
return this.name;
};
GraphNode.prototype.getPath = function () {
Debug.deprecated('pc.GraphNode#getPath is deprecated. Use pc.GraphNode#path instead.');
return this.path;
};
GraphNode.prototype.getRoot = function () {
Debug.deprecated('pc.GraphNode#getRoot is deprecated. Use pc.GraphNode#root instead.');
return this.root;
};
GraphNode.prototype.getParent = function () {
Debug.deprecated('pc.GraphNode#getParent is deprecated. Use pc.GraphNode#parent instead.');
return this.parent;
};
GraphNode.prototype.setName = function (name) {
Debug.deprecated('pc.GraphNode#setName is deprecated. Use pc.GraphNode#name instead.');
this.name = name;
};
Object.defineProperty(Material.prototype, 'shader', {
set: function (value) {
Debug.deprecated('pc.Material#shader is deprecated, use pc.ShaderMaterial instead.');
},
get: function () {
Debug.deprecated('pc.Material#shader is deprecated, use pc.ShaderMaterial instead.');
return null;
}
});
// Note: this is used by the Editor
Object.defineProperty(Material.prototype, 'blend', {
set: function (value) {
Debug.deprecated('pc.Material#blend is deprecated, use pc.Material.blendState.');
this.blendState.blend = value;
},
get: function () {
return this.blendState.blend;
}
});
// shininess (range 0..100) - maps to internal gloss value (range 0..1)
Object.defineProperty(StandardMaterial.prototype, 'shininess', {
get: function () {
return this.gloss * 100;
},
set: function (value) {
this.gloss = value * 0.01;
}
});
// useGammaTonemap was renamed to useTonemap. For now do not log a deprecated warning to make existing
// code work without warnings.
Object.defineProperty(StandardMaterial.prototype, 'useGammaTonemap', {
get: function () {
return this.useTonemap;
},
set: function (value) {
this.useTonemap = value;
}
});
function _defineAlias(newName, oldName) {
Object.defineProperty(StandardMaterial.prototype, oldName, {
get: function () {
Debug.deprecated(`pc.StandardMaterial#${oldName} is deprecated. Use pc.StandardMaterial#${newName} instead.`);
return this[newName];
},
set: function (value) {
Debug.deprecated(`pc.StandardMaterial#${oldName} is deprecated. Use pc.StandardMaterial#${newName} instead.`);
this[newName] = value;
}
});
}
function _deprecateTint(name) {
Object.defineProperty(StandardMaterial.prototype, name, {
get: function () {
Debug.deprecated(`pc.StandardMaterial#${name} is deprecated, and the behaviour is as if ${name} was always true`);
return true;
},
set: function (value) {
Debug.deprecated(`pc.StandardMaterial#${name} is deprecated, and the behaviour is as if ${name} was always true`);
}
});
}
_deprecateTint('sheenTint');
_deprecateTint('diffuseTint');
_deprecateTint('emissiveTint');
_deprecateTint('ambientTint');
_defineAlias('specularTint', 'specularMapTint');
_defineAlias('aoVertexColor', 'aoMapVertexColor');
_defineAlias('diffuseVertexColor', 'diffuseMapVertexColor');
_defineAlias('specularVertexColor', 'specularMapVertexColor');
_defineAlias('emissiveVertexColor', 'emissiveMapVertexColor');
_defineAlias('metalnessVertexColor', 'metalnessMapVertexColor');
_defineAlias('glossVertexColor', 'glossMapVertexColor');
_defineAlias('opacityVertexColor', 'opacityMapVertexColor');
_defineAlias('lightVertexColor', 'lightMapVertexColor');
_defineAlias('sheenGloss', 'sheenGlossiess');
_defineAlias('clearCoatGloss', 'clearCostGlossiness');
function _defineOption(name, newName) {
if (name !== 'pass') {
Object.defineProperty(StandardMaterialOptions.prototype, name, {
get: function () {
Debug.deprecated(`Getting pc.Options#${name} has been deprecated as the property has been moved to pc.Options.LitShaderOptions#${newName || name}.`);
return this.litOptions[newName || name];
},
set: function (value) {
Debug.deprecated(`Setting pc.Options#${name} has been deprecated as the property has been moved to pc.Options.LitShaderOptions#${newName || name}.`);
this.litOptions[newName || name] = value;
}
});
}
}
_defineOption('refraction', 'useRefraction');
const tempOptions = new LitShaderOptions();
const litOptionProperties = Object.getOwnPropertyNames(tempOptions);
for (const litOption in litOptionProperties) {
_defineOption(litOptionProperties[litOption]);
}
// ASSET
AssetRegistry.prototype.getAssetById = function (id) {
Debug.deprecated('pc.AssetRegistry#getAssetById is deprecated. Use pc.AssetRegistry#get instead.');
return this.get(id);
};
// XR
Object.defineProperty(XrInputSource.prototype, 'ray', {
get: function () {
Debug.deprecated('pc.XrInputSource#ray is deprecated. Use pc.XrInputSource#getOrigin and pc.XrInputSource#getDirection instead.');
return this._rayLocal;
}
});
Object.defineProperty(XrInputSource.prototype, 'position', {
get: function () {
Debug.deprecated('pc.XrInputSource#position is deprecated. Use pc.XrInputSource#getLocalPosition instead.');
return this._localPosition;
}
});
Object.defineProperty(XrInputSource.prototype, 'rotation', {
get: function () {
Debug.deprecated('pc.XrInputSource#rotation is deprecated. Use pc.XrInputSource#getLocalRotation instead.');
return this._localRotation;
}
});
// INPUT
Object.defineProperty(ElementInput.prototype, 'wheel', {
get: function () {
return this.wheelDelta * -2;
}
});
Object.defineProperty(MouseEvent.prototype, 'wheel', {
get: function () {
return this.wheelDelta * -2;
}
});
// FRAMEWORK
export const RIGIDBODY_TYPE_STATIC = BODYTYPE_STATIC;
export const RIGIDBODY_TYPE_DYNAMIC = BODYTYPE_DYNAMIC;
export const RIGIDBODY_TYPE_KINEMATIC = BODYTYPE_KINEMATIC;
export const RIGIDBODY_CF_STATIC_OBJECT = BODYFLAG_STATIC_OBJECT;
export const RIGIDBODY_CF_KINEMATIC_OBJECT = BODYFLAG_KINEMATIC_OBJECT;
export const RIGIDBODY_CF_NORESPONSE_OBJECT = BODYFLAG_NORESPONSE_OBJECT;
export const RIGIDBODY_ACTIVE_TAG = BODYSTATE_ACTIVE_TAG;
export const RIGIDBODY_ISLAND_SLEEPING = BODYSTATE_ISLAND_SLEEPING;
export const RIGIDBODY_WANTS_DEACTIVATION = BODYSTATE_WANTS_DEACTIVATION;
export const RIGIDBODY_DISABLE_DEACTIVATION = BODYSTATE_DISABLE_DEACTIVATION;
export const RIGIDBODY_DISABLE_SIMULATION = BODYSTATE_DISABLE_SIMULATION;
AppBase.prototype.isFullscreen = function () {
Debug.deprecated('pc.AppBase#isFullscreen is deprecated. Use the Fullscreen API directly.');
return !!document.fullscreenElement;
};
AppBase.prototype.enableFullscreen = function (element, success, error) {
Debug.deprecated('pc.AppBase#enableFullscreen is deprecated. Use the Fullscreen API directly.');
element = element || this.graphicsDevice.canvas;
// success callback
const s = function () {
success();
document.removeEventListener('fullscreenchange', s);
};
// error callback
const e = function () {
error();
document.removeEventListener('fullscreenerror', e);
};
if (success) {
document.addEventListener('fullscreenchange', s, false);
}
if (error) {
document.addEventListener('fullscreenerror', e, false);
}
if (element.requestFullscreen) {
element.requestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
} else {
error();
}
};
AppBase.prototype.disableFullscreen = function (success) {
Debug.deprecated('pc.AppBase#disableFullscreen is deprecated. Use the Fullscreen API directly.');
// success callback
const s = function () {
success();
document.removeEventListener('fullscreenchange', s);
};
if (success) {
document.addEventListener('fullscreenchange', s, false);
}
document.exitFullscreen();
};
AppBase.prototype.getSceneUrl = function (name) {
Debug.deprecated('pc.AppBase#getSceneUrl is deprecated. Use pc.AppBase#scenes and pc.SceneRegistry#find instead.');
const entry = this.scenes.find(name);
if (entry) {
return entry.url;
}
return null;
};
AppBase.prototype.loadScene = function (url, callback) {
Debug.deprecated('pc.AppBase#loadScene is deprecated. Use pc.AppBase#scenes and pc.SceneRegistry#loadScene instead.');
this.scenes.loadScene(url, callback);
};
AppBase.prototype.loadSceneHierarchy = function (url, callback) {
Debug.deprecated('pc.AppBase#loadSceneHierarchy is deprecated. Use pc.AppBase#scenes and pc.SceneRegistry#loadSceneHierarchy instead.');
this.scenes.loadSceneHierarchy(url, callback);
};
AppBase.prototype.loadSceneSettings = function (url, callback) {
Debug.deprecated('pc.AppBase#loadSceneSettings is deprecated. Use pc.AppBase#scenes and pc.SceneRegistry#loadSceneSettings instead.');
this.scenes.loadSceneSettings(url, callback);
};
ModelComponent.prototype.setVisible = function (visible) {
Debug.deprecated('pc.ModelComponent#setVisible is deprecated. Use pc.ModelComponent#enabled instead.');
this.enabled = visible;
};
Object.defineProperty(RigidBodyComponent.prototype, 'bodyType', {
get: function () {
Debug.deprecated('pc.RigidBodyComponent#bodyType is deprecated. Use pc.RigidBodyComponent#type instead.');
return this.type;
},
set: function (type) {
Debug.deprecated('pc.RigidBodyComponent#bodyType is deprecated. Use pc.RigidBodyComponent#type instead.');
this.type = type;
}
});
RigidBodyComponent.prototype.syncBodyToEntity = function () {
Debug.deprecated('pc.RigidBodyComponent#syncBodyToEntity is not public API and should not be used.');
this._updateDynamic();
};
RigidBodyComponentSystem.prototype.setGravity = function () {
Debug.deprecated('pc.RigidBodyComponentSystem#setGravity is deprecated. Use pc.RigidBodyComponentSystem#gravity instead.');
if (arguments.length === 1) {
this.gravity.copy(arguments[0]);
} else {
this.gravity.set(arguments[0], arguments[1], arguments[2]);
}
};