@woosh/meep-engine 2.75.8 → 2.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +784 -982
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +784 -982
  5. package/editor/actions/concrete/ModifyPatchSampler2DAction.js +6 -3
  6. package/editor/actions/concrete/PatchTerrainTextureAction.js +6 -3
  7. package/editor/process/EditorProcess.js +12 -16
  8. package/editor/process/ProcessEngine.js +9 -10
  9. package/package.json +1 -1
  10. package/src/core/binary/dec2hex.js +1 -1
  11. package/src/{engine/ecs/ik/IKMath.js → core/geom/vec3/v3_computeOffsetVector.js} +1 -1
  12. package/src/core/math/newton_solver_1d.js +13 -4
  13. package/src/{engine/graphics → core/math/random}/generate_halton_jitter.js +2 -2
  14. package/src/core/math/solveQuadratic.js +5 -3
  15. package/src/core/math/spline/catmull_rom_compute_T.js +19 -0
  16. package/src/{engine/navigation/ecs/components → core/math/spline}/computeCatmullRomSpline.js +3 -3
  17. package/src/{engine/navigation/ecs/components → core/math/spline}/computeCatmullRomSplineUniformDistance.js +3 -3
  18. package/src/core/math/spline/computeNonuniformCatmullRomSplineSample.js +109 -0
  19. package/src/core/math/spline/interpolate_bicubic.js +12 -0
  20. package/src/core/math/spline/spline_catmullrom_1d.js +120 -0
  21. package/src/engine/control/ControlContext.js +25 -27
  22. package/src/engine/ecs/EntityManager.js +12 -9
  23. package/src/engine/ecs/EntityObserver.js +26 -22
  24. package/src/engine/ecs/binding/ComponentPropertyPath.js +12 -12
  25. package/src/engine/ecs/components/Motion.js +5 -7
  26. package/src/engine/ecs/components/SerializationMetadata.js +5 -3
  27. package/src/engine/ecs/dynamic_actions/actions/definition/AbstractActionDescription.js +0 -2
  28. package/src/engine/ecs/dynamic_actions/actions/definition/ActionSequenceDescription.js +7 -9
  29. package/src/engine/ecs/dynamic_actions/actions/definition/DelayActionDescription.js +3 -5
  30. package/src/engine/ecs/dynamic_actions/actions/definition/SendRequestActionDescription.js +6 -8
  31. package/src/engine/ecs/dynamic_actions/actions/definition/SpeakLineActionDescription.js +14 -17
  32. package/src/engine/ecs/dynamic_actions/actions/definition/WeightedRandomActionDescription.js +8 -11
  33. package/src/engine/ecs/dynamic_actions/actions/definition/WriteToBlackboardActionDescription.js +15 -18
  34. package/src/engine/ecs/ik/OneBoneSurfaceAlignmentSolver.js +7 -7
  35. package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.js +6 -6
  36. package/src/engine/ecs/parent/EntityNode.js +39 -37
  37. package/src/engine/ecs/speaker/VoiceSystem.js +36 -39
  38. package/src/engine/ecs/system/SystemEntityContext.js +25 -23
  39. package/src/engine/ecs/tag/find_entities_with_tag.js +18 -0
  40. package/src/engine/ecs/terrain/TerrainClouds.js +23 -24
  41. package/src/engine/ecs/terrain/ecs/splat/SplatMapMaterialPatch.js +5 -2
  42. package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +15 -14
  43. package/src/engine/ecs/tooltip/TooltipComponent.js +6 -7
  44. package/src/engine/graphics/camera/testClippingPlaneComputation.js +0 -4
  45. package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +1 -5
  46. package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +2 -6
  47. package/src/engine/graphics/ecs/water2/shader/testWaterShader.js +12 -14
  48. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +22 -20
  49. package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +3 -4
  50. package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -4
  51. package/src/engine/graphics/render/buffer/simple-fx/taa/TemporalSupersamplingRenderPlugin.js +1 -1
  52. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +0 -4
  53. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +0 -4
  54. package/src/engine/graphics/shadows/testShadowMapRendering.js +0 -2
  55. package/src/engine/graphics/texture/atlas/TextureAtlas.js +13 -11
  56. package/src/engine/graphics/texture/sampler/Sampler2D.js +15 -366
  57. package/src/engine/graphics/texture/sampler/Sampler2D.spec.js +0 -31
  58. package/src/engine/graphics/texture/sampler/sampler2d_copy_with_margins.js +166 -0
  59. package/src/engine/graphics/texture/sampler/sampler2d_copy_with_margins.spec.js +31 -0
  60. package/src/engine/graphics/texture/sampler/sampler2d_paint.js +81 -0
  61. package/src/engine/graphics/texture/sampler/sampler2d_sub_copy_same_item_size.js +50 -0
  62. package/src/engine/graphics/texture/virtual/VirtualTextureUsageUpdater.js +1 -1
  63. package/src/engine/navigation/ecs/components/Path.js +10 -9
  64. package/src/engine/physics/computeInterceptPoint.js +44 -0
  65. package/src/engine/plugin/EnginePlugin.js +1 -2
  66. package/src/engine/ecs/components/AlignToVelocity.js +0 -9
  67. package/src/engine/ecs/components/CharacterController.js +0 -31
  68. package/src/engine/ecs/components/PhysicalBody.js +0 -51
  69. package/src/engine/ecs/components/Steering.js +0 -111
  70. package/src/engine/ecs/components/SteeringSerializationAdapter.js +0 -34
  71. package/src/engine/ecs/systems/AlignToVelocitySystem.js +0 -51
  72. package/src/engine/ecs/systems/CharacterControlSystem.js +0 -134
  73. package/src/engine/ecs/systems/PhysicsSystem.js +0 -89
  74. package/src/engine/ecs/systems/PropertySetSystem.js +0 -18
  75. package/src/engine/ecs/systems/SteeringSystem.js +0 -171
  76. package/src/engine/ecs/systems/TagSystem.d.ts +0 -5
  77. package/src/engine/ecs/systems/TagSystem.js +0 -31
  78. package/src/engine/graphics/CanvasBlur.js +0 -599
  79. package/src/engine/graphics/material/LoadMaterial.js +0 -199
  80. package/src/engine/graphics/material/getTextureImmediate.js +0 -21
  81. package/src/engine/graphics/render/buffer/RenderGraph.js +0 -177
  82. package/src/engine/graphics/render/buffer/RenderGraphUtils.js +0 -32
  83. package/src/engine/graphics/render/buffer/buffers/DepthFrameBuffer.js +0 -101
  84. package/src/engine/graphics/render/buffer/conection/ProgramValueSlotConnection.js +0 -43
  85. package/src/engine/graphics/render/buffer/conection/ProgramValueSlotConnectionEndpoint.js +0 -39
  86. package/src/engine/graphics/render/buffer/conection/ProgramValueSlotConnectionValidator.js +0 -30
  87. package/src/engine/graphics/render/buffer/executor/FrameBufferPool.js +0 -127
  88. package/src/engine/graphics/render/buffer/executor/RenderGraphExecutor.js +0 -261
  89. package/src/engine/graphics/render/buffer/executor/RenderProgramCommandType.js +0 -5
  90. package/src/engine/graphics/render/buffer/node/DeferredRenderProgramDefinition.js +0 -142
  91. package/src/engine/graphics/render/buffer/node/RenderProgramDefinition.js +0 -21
  92. package/src/engine/graphics/render/buffer/node/RenderProgramInstance.js +0 -30
  93. package/src/engine/graphics/render/buffer/node/ScreenSpaceRenderProgramDefinition.js +0 -118
  94. package/src/engine/graphics/render/staged/PostProcessingEffect.js +0 -32
  95. package/src/engine/graphics/render/staged/PostProcessingEffectInputCoupling.js +0 -41
  96. package/src/engine/graphics/render/staged/PostProcessingStack.js +0 -29
  97. package/src/engine/graphics/render/staged/StagedRenderer.js +0 -161
  98. package/src/engine/graphics/render/staged/StandardRenderOutputs.js +0 -20
  99. package/src/engine/graphics/texture/CanvasClone.js +0 -28
  100. package/src/engine/graphics/texture/sampler/bicubic.js +0 -59
  101. package/src/engine/graphics/texture/sampler/bicubic.spec.js +0 -13
  102. package/src/engine/graphics/texture/sampler/differenceSampler.js +0 -36
  103. package/src/engine/graphics/texture/sampler/loadSampler2D.js +0 -41
  104. package/src/engine/graphics/texture/sampler/mergeSampler2D.js +0 -96
  105. package/src/engine/graphics/texture/sampler/rgbaData2valueSampler2D.js +0 -38
  106. package/src/engine/navigation/ecs/components/computeNonuniformCatmullRomSplineSample.js +0 -242
  107. /package/src/{engine/graphics/texture → core/math/noise}/noise_octaves.js +0 -0
@@ -1,199 +0,0 @@
1
- /**
2
- * Created by Alex on 16/10/2014.
3
- */
4
-
5
-
6
- import {
7
- ClampToEdgeWrapping,
8
- DataTexture,
9
- FrontSide,
10
- LinearEncoding,
11
- LinearFilter,
12
- LinearMipMapLinearFilter,
13
- MeshBasicMaterial,
14
- MeshPhongMaterial,
15
- RepeatWrapping,
16
- RGBAFormat,
17
- sRGBEncoding,
18
- UnsignedByteType
19
- } from 'three';
20
- import { SplatMaterial } from "./SplatMaterial.js";
21
- import WaterMaterial from "./WaterMaterial.js";
22
- import loadSampler2D from "../texture/sampler/loadSampler2D.js";
23
- import { mergeSampler2D } from "../texture/sampler/mergeSampler2D.js";
24
- import { getTextureImmediate } from "./getTextureImmediate.js";
25
-
26
- /**
27
- * @param textures
28
- * @param repeat
29
- * @param type
30
- * @param gridResolution
31
- * @param bumpScale
32
- * @param transparent
33
- * @param {AssetManager} assetManager
34
- */
35
- export default function loadMaterial(
36
- {
37
- textures,
38
- repeat = { x: 1, y: 1 },
39
- type,
40
- gridResolution,
41
- bumpScale = 1,
42
- transparent = false,
43
- assetManager
44
- }
45
- ) {
46
- let material;
47
- //
48
- const diffuse = textures.diffuse;
49
- const normal = textures.normal;
50
- const light = textures.light;
51
- const bump = textures.bump;
52
- const specular = textures.specular;
53
-
54
- /**
55
- *
56
- * @param {Texture} t
57
- */
58
- function setTextureParameters(t) {
59
- t.wrapS = RepeatWrapping;
60
- t.wrapT = RepeatWrapping;
61
- t.repeat.set(repeat.x, repeat.y);
62
- t.anisotropy = 8;
63
- t.encoding = sRGBEncoding;
64
-
65
- t.minFilter = LinearMipMapLinearFilter;
66
- t.magFilter = LinearFilter;
67
- }
68
-
69
- /**
70
- *
71
- * @param param
72
- * @param callback
73
- * @returns {Texture}
74
- */
75
- function loadTexture(param, callback) {
76
- if (param.isTexture) {
77
- return param;
78
- }
79
-
80
- const t = getTextureImmediate(param, assetManager);
81
-
82
- setTextureParameters(t);
83
-
84
- return t;
85
- }
86
-
87
- let result = {};
88
-
89
- let o;
90
- //treat splat differently
91
- if (type === "splat") {
92
-
93
- let splatMap;
94
- //deal with a case where splat map is an missing, and instead "splatMaps' are given
95
- if (textures.splat !== undefined && textures.splat.length !== undefined && textures.splat instanceof Array) {
96
- splatMap = new DataTexture();
97
- setTextureParameters(splatMap);
98
-
99
- const promises = textures.splat.map((url) => loadSampler2D(url, assetManager));
100
-
101
- result.splat = {
102
- samplers: promises
103
- };
104
-
105
- Promise.all(promises).then(function (results) {
106
- const merged = mergeSampler2D(results);
107
- splatMap.format = RGBAFormat;
108
- splatMap.type = UnsignedByteType;
109
- splatMap.flipY = true;
110
- splatMap.image = { data: merged.data, width: merged.width, height: merged.height };
111
- splatMap.needsUpdate = true;
112
-
113
- //No wrapping for splat maps
114
- splatMap.wrapT = ClampToEdgeWrapping;
115
- splatMap.wrapS = ClampToEdgeWrapping;
116
-
117
- splatMap.encoding = LinearEncoding;
118
- splatMap.needsUpdate = true;
119
- }, function (error) {
120
- console.error(error);
121
- });
122
- } else {
123
- splatMap = loadTexture(textures.splat);
124
- }
125
-
126
- /**
127
- * @type {Texture[]}
128
- */
129
- const diffuseTextures = textures.diffuse
130
- .map(loadTexture);
131
-
132
- o = {
133
- splatMap: splatMap,
134
- diffuseMaps: diffuseTextures
135
- .map(t => {
136
- t.encoding = sRGBEncoding;
137
-
138
- return t;
139
- }),
140
- gridResolution
141
- };
142
- } else {
143
- o = {
144
- specular: 0,
145
- shininess: 10,
146
- color: 0xFFFFFF,
147
- side: FrontSide,
148
- flatShading: false
149
- };
150
- if (diffuse !== void 0 && !(diffuse instanceof Array)) {
151
- o.map = loadTexture(diffuse);
152
- }
153
- if (normal !== void 0) {
154
- o.normalMap = loadTexture(normal);
155
- }
156
- if (bump !== void 0) {
157
- o.bumpMap = loadTexture(bump);
158
- o.bumpScale = bumpScale;
159
- }
160
- if (specular !== void 0) {
161
- o.specularMap = loadTexture(specular);
162
- o.shininess = 50;
163
- o.specular = 0x333333;
164
- }
165
- }
166
- //
167
- if (transparent) {
168
- o.transparent = true;
169
- }
170
- if (light !== void 0) {
171
- o.lightMap = loadTexture(light);
172
- }
173
-
174
- switch (type) {
175
- case "basic":
176
- material = new MeshBasicMaterial(o);
177
- break;
178
- case "splat":
179
- //load diffuse maps
180
- material = new SplatMaterial(o);
181
-
182
- if (light) {
183
- material.uniforms.lightMap.value = o.lightMap;
184
- }
185
-
186
- break;
187
- case "water":
188
- material = new WaterMaterial(o);
189
- break;
190
- default :
191
- case "phong":
192
- material = new MeshPhongMaterial(o);
193
- break;
194
- }
195
-
196
- result.material = material;
197
-
198
- return result;
199
- };
@@ -1,21 +0,0 @@
1
- import { GameAssetType } from "../../asset/GameAssetType.js";
2
- import { noop } from "../../../core/function/Functions.js";
3
-
4
- /**
5
- *
6
- * @param {string} url
7
- * @param {AssetManager} assetManager
8
- * @returns {Texture|undefined}
9
- */
10
- export function getTextureImmediate(url, assetManager) {
11
-
12
- let t;
13
-
14
- assetManager.get({
15
- path: url, type: GameAssetType.DeferredTexture, callback: function (asset) {
16
- t = asset.create();
17
- }, failure: noop
18
- });
19
-
20
- return t;
21
- }
@@ -1,177 +0,0 @@
1
- import { assert } from "../../../../core/assert.js";
2
- import { ProgramValueSlotConnection } from "./conection/ProgramValueSlotConnection.js";
3
- import { ProgramValueSlotConnectionEndpoint } from "./conection/ProgramValueSlotConnectionEndpoint.js";
4
- import { RenderProgramInstance } from "./node/RenderProgramInstance.js";
5
- import { ProgramValueType } from "./slot/ProgramValueType.js";
6
-
7
- export class RenderGraph {
8
-
9
- /**
10
- *
11
- * @type {RenderProgramInstance[]}
12
- */
13
- nodes = [];
14
- /**
15
- *
16
- * @type {ProgramValueSlotConnection[]}
17
- */
18
- connections = [];
19
-
20
- /**
21
- *
22
- * @type {ProgramValueSlotConnectionEndpoint|null}
23
- */
24
- finalOutput = null;
25
-
26
-
27
- /**
28
- *
29
- * @param {RenderProgramInstance} node
30
- * @param {ProgramValueSlotDefinition} slot
31
- */
32
- setFinalOutput(node, slot) {
33
- assert.ok(this.containsNode(node), 'Node is not contained in the graph');
34
-
35
- assert.equal(slot.type, ProgramValueType.FrameBuffer, `expected slot type to be FrameBuffer, instead was '${slot.type}'`);
36
-
37
- this.finalOutput = new ProgramValueSlotConnectionEndpoint({ node, slot });
38
- }
39
-
40
- /**
41
- *
42
- * @param {RenderProgramInstance} node
43
- * @returns {boolean}
44
- */
45
- containsNode(node) {
46
- return this.nodes.some(n => n === node);
47
- }
48
-
49
- /**
50
- *
51
- * @param {RenderProgramDefinition} definition
52
- */
53
- createNode(definition) {
54
- const instance = new RenderProgramInstance({ definition });
55
-
56
- this.addNode(instance);
57
-
58
- return instance;
59
- }
60
-
61
- /**
62
- *
63
- * @param {RenderProgramInstance} node
64
- * @returns {boolean}
65
- */
66
- addNode(node) {
67
- if (this.containsNode(node)) {
68
- //graph already contains the node
69
- return false;
70
- }
71
-
72
- this.nodes.push(node);
73
-
74
- return true;
75
- }
76
-
77
- /**
78
- *
79
- * @param {RenderProgramInstance} sourceInstance
80
- * @param {ProgramValueSlotDefinition} sourceSlot
81
- * @param {RenderProgramInstance} targetInstance
82
- * @param {ProgramValueSlotDefinition} targetSlot
83
- * @returns {ProgramValueSlotConnection}
84
- */
85
- createConnection(sourceInstance, sourceSlot, targetInstance, targetSlot) {
86
- const sourceEndpoint = new ProgramValueSlotConnectionEndpoint({ node: sourceInstance, slot: sourceSlot });
87
- const targetEndpoint = new ProgramValueSlotConnectionEndpoint({ node: targetInstance, slot: targetSlot });
88
-
89
- const connection = new ProgramValueSlotConnection({ source: sourceEndpoint, target: targetEndpoint });
90
-
91
- this.addConnection(connection);
92
-
93
- return connection;
94
- }
95
-
96
- /**
97
- *
98
- * @param {ProgramValueSlotConnection} connection
99
- */
100
- addConnection(connection) {
101
- assert.ok(this.containsNode(connection.source.node), 'Connection source node is not a part of the graph');
102
- assert.ok(this.containsNode(connection.target.node), 'Connection target node is not a part of the graph');
103
-
104
- //add connection to source and target instance slots
105
- connection.source.node.getSlotValue(connection.source.slot).addConnection(connection);
106
- connection.target.node.getSlotValue(connection.target.slot).addConnection(connection);
107
-
108
- this.connections.push(connection);
109
- }
110
-
111
- /**
112
- * Returns node that contains screen output
113
- * @returns {RenderProgramInstance|null}
114
- */
115
- getTerminalNode() {
116
- return this.finalOutput.node;
117
- }
118
-
119
- /**
120
- *
121
- * @param {RenderProgramInstance} node
122
- * @returns {ProgramValueSlotConnection[]}
123
- */
124
- getConnectionsByNode(node) {
125
- return this.connections.filter(function (c) {
126
- return c.source.node === node || c.target.node === node;
127
- });
128
- }
129
-
130
- /**
131
- * Computes set of nodes that produce inputs for parameter node
132
- * @param {RenderProgramInstance} node
133
- * @returns {RenderProgramInstance[]}
134
- */
135
- getPredecessorNodes(node) {
136
- return this.connections.filter(function (c) {
137
- return c.target.node === node;
138
- }).map(function (c) {
139
- return c.source.node;
140
- });
141
- }
142
-
143
- /**
144
- *
145
- * @param {RenderProgramInstance} node
146
- * @return {number}
147
- */
148
- computeNodeDepth(node) {
149
- const predecessors = this.getPredecessorNodes(node);
150
-
151
- if (predecessors.length === 0) {
152
- return 0;
153
- } else {
154
- return Math.max.apply(null, predecessors.map(p => this.computeNodeDepth(p)));
155
- }
156
- }
157
-
158
- /**
159
- *
160
- * @param {function} visitor
161
- */
162
- traverseNodes(visitor) {
163
- const nodes = this.nodes;
164
-
165
- const numNodes = nodes.length;
166
-
167
- for (let i = 0; i < numNodes; i++) {
168
- const programInstance = nodes[i];
169
-
170
- const continueFlag = visitor(programInstance);
171
-
172
- if (continueFlag === false) {
173
- return;
174
- }
175
- }
176
- }
177
- }
@@ -1,32 +0,0 @@
1
- import { RenderGraph } from "./RenderGraph.js";
2
- import { RenderProgramDefinition } from "./node/RenderProgramDefinition.js";
3
- import { ProgramValueSlotDefinition } from "./slot/ProgramValueSlotDefinition.js";
4
- import { ProgramValueDirectionKind } from "./slot/ProgramValueDirectionKind.js";
5
- import { ProgramValueType } from "./slot/ProgramValueType.js";
6
-
7
- export function buildRenderGraph() {
8
- const graph = new RenderGraph();
9
-
10
- const outDepth = new ProgramValueSlotDefinition({
11
- name: 'output',
12
- direction: ProgramValueDirectionKind.Out,
13
- type: ProgramValueType.FrameBuffer
14
- });
15
-
16
- const outColor = new ProgramValueSlotDefinition({
17
- name: 'output',
18
- direction: ProgramValueDirectionKind.Out,
19
- type: ProgramValueType.FrameBuffer
20
- });
21
-
22
- const pColor = new RenderProgramDefinition();
23
- pColor.slots.push(outColor);
24
-
25
- const pDepth = new RenderProgramDefinition();
26
- pDepth.slots.push(outDepth);
27
-
28
- const piColor = graph.createNode(pColor);
29
- const piDepth = graph.createNode(pDepth);
30
-
31
-
32
- }
@@ -1,101 +0,0 @@
1
- import {
2
- FrontSide,
3
- LinearFilter,
4
- MeshDepthMaterial,
5
- NoBlending,
6
- RGBADepthPacking,
7
- RGBAFormat,
8
- WebGLRenderTarget
9
- } from "three";
10
- import { FrameBuffer } from "../FrameBuffer.js";
11
-
12
-
13
- export class DepthFrameBuffer extends FrameBuffer {
14
- initialize(renderer) {
15
- const depthMaterialStatic = new MeshDepthMaterial();
16
- depthMaterialStatic.depthPacking = RGBADepthPacking;
17
- depthMaterialStatic.blending = NoBlending;
18
- depthMaterialStatic.side = FrontSide;
19
-
20
- const materialMap = [];
21
-
22
- this.depthMaterialStatic = depthMaterialStatic;
23
- this.materialMap = materialMap;
24
-
25
- this.renderTarget = new WebGLRenderTarget(this.size.x, this.size.y, {
26
- minFilter: LinearFilter,
27
- magFilter: LinearFilter,
28
- format: RGBAFormat,
29
- stencilBuffer: false,
30
- generateMipmaps: false
31
- });
32
- }
33
-
34
- render(renderer, camera, scene) {
35
- const renderTarget = this.renderTarget;
36
-
37
- const materialMap = this.materialMap;
38
- const depthMaterialStatic = this.depthMaterialStatic;
39
-
40
- // remember renderer state
41
- const currentXrEnabled = renderer.xr.enabled;
42
- const currentShadowAutoUpdate = renderer.shadowMap.autoUpdate;
43
-
44
- renderer.xr.enabled = false; // Avoid camera modification and recursion
45
- renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
46
-
47
- scene.overrideMaterial = null;
48
-
49
- /**
50
- *
51
- * @param {Object3D} object
52
- */
53
- function visitSceneObject(object) {
54
- const material = object.material;
55
- if (material !== undefined && material.depthWrite) {
56
- //remember old material
57
- materialMap[object.id] = material;
58
-
59
- //set new material
60
- if (material.customDepthMaterial !== undefined) {
61
- object.material = material.customDepthMaterial;
62
- } else {
63
- object.material = depthMaterialStatic;
64
- }
65
- }
66
- }
67
-
68
- //replace materials in the scene
69
- scene.traverse(visitSceneObject);
70
-
71
- const oldRenderTarget = renderer.getRenderTarget();
72
-
73
- renderer.setRenderTarget(renderTarget);
74
- renderer.clear();
75
-
76
- renderer.render(scene, camera);
77
-
78
- renderer.setRenderTarget(oldRenderTarget);
79
-
80
- //restore materials
81
- scene.traverse(function (object) {
82
- const material = object.material;
83
- if (material !== undefined) {
84
- const id = object.id;
85
- const m = materialMap[id];
86
- if (m !== undefined) {
87
- object.material = m;
88
-
89
- delete materialMap[id];
90
- }
91
- }
92
- });
93
-
94
- // restore renderer
95
- scene.overrideMaterial = null;
96
-
97
- renderer.xr.enabled = currentXrEnabled;
98
- renderer.shadowMap.autoUpdate = currentShadowAutoUpdate;
99
- }
100
- }
101
-
@@ -1,43 +0,0 @@
1
- import { assert } from "../../../../../core/assert.js";
2
- import { ProgramValueDirectionKind } from "../slot/ProgramValueDirectionKind.js";
3
-
4
- export class ProgramValueSlotConnection {
5
- /**
6
- *
7
- * @param {ProgramValueSlotConnectionEndpoint} source
8
- * @param {ProgramValueSlotConnectionEndpoint} target
9
- */
10
- constructor({ source, target }) {
11
- assert.notEqual(source, undefined, 'source is undefined');
12
- assert.notEqual(target, undefined, 'target is undefined');
13
-
14
- assert.typeOf(source, 'object', 'source');
15
- assert.typeOf(target, 'object', 'target');
16
-
17
- assert.equal(source.slot.direction, ProgramValueDirectionKind.Out, `expected source slot direction to be Out, instead was '${source.slot.direction}'`);
18
- assert.equal(target.slot.direction, ProgramValueDirectionKind.In, `expected source slot direction to be In, instead was '${target.slot.direction}'`);
19
-
20
- assert.equal(source.slot.type, target.slot.type, `source(${source.slot.type}) and target(${target.slot.type}) slot types do not match`)
21
-
22
- /**
23
- *
24
- * @type {ProgramValueSlotConnectionEndpoint}
25
- */
26
- this.source = source;
27
-
28
- /**
29
- *
30
- * @type {ProgramValueSlotConnectionEndpoint}
31
- */
32
- this.target = target;
33
- }
34
-
35
- /**
36
- *
37
- * @param {ProgramValueSlotConnection} other
38
- * @returns {boolean}
39
- */
40
- equals(other) {
41
- return this.source.equals(other.source) && this.target.equals(other.target);
42
- }
43
- }
@@ -1,39 +0,0 @@
1
- import { assert } from "../../../../../core/assert.js";
2
-
3
- export class ProgramValueSlotConnectionEndpoint {
4
- /**
5
- *
6
- * @param {RenderProgramInstance} node
7
- * @param {ProgramValueSlotDefinition} slot
8
- */
9
- constructor({ node, slot }) {
10
- assert.notEqual(node, undefined, 'node is undefined');
11
- assert.notEqual(slot, undefined, 'slot is undefined');
12
-
13
- assert.typeOf(node, 'object', 'node');
14
- assert.typeOf(slot, 'object', 'slot');
15
-
16
- assert.notEqual(node.definition.slots.indexOf(slot), -1, 'node does not contain specified slot');
17
-
18
- /**
19
- *
20
- * @type {RenderProgramInstance}
21
- */
22
- this.node = node;
23
- /**
24
- *
25
- * @type {ProgramValueSlotDefinition}
26
- */
27
- this.slot = slot;
28
- }
29
-
30
- /**
31
- *
32
- * @param {ProgramValueSlotConnectionEndpoint} other
33
- * @returns {boolean}
34
- */
35
- equals(other) {
36
- return (this.node === other.node) && (this.slot === other.slot)
37
- }
38
-
39
- }
@@ -1,30 +0,0 @@
1
- import { ProgramValueDirectionKind } from "../slot/ProgramValueDirectionKind.js";
2
-
3
- export class ProgramValueSlotConnectionValidator {
4
- constructor() {
5
-
6
- }
7
-
8
- /**
9
- *
10
- * @param {ProgramValueSlotConnection} connection
11
- */
12
- validate(connection) {
13
-
14
- const sourceEndpoint = connection.source;
15
-
16
- if (sourceEndpoint.slot.direction === ProgramValueDirectionKind.In) {
17
- //source slot must not be an input
18
- return false;
19
- }
20
-
21
- const targetEndpoint = connection.target;
22
-
23
- if (targetEndpoint.slot.direction === ProgramValueDirectionKind.Out) {
24
- //target slot must not be an output
25
- return false;
26
- }
27
-
28
- return true;
29
- }
30
- }