@flighthq/render 0.2.1-next.738.07b221d → 0.2.1-next.841.373388f
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.
- package/dist/explainScene2DRender.d.ts +3 -0
- package/dist/explainScene2DRender.d.ts.map +1 -0
- package/dist/{explainDisplayObjectRender.js → explainScene2DRender.js} +3 -3
- package/dist/explainScene2DRender.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/renderProxy.d.ts +2 -2
- package/dist/renderProxy.d.ts.map +1 -1
- package/dist/renderProxy.js +13 -13
- package/dist/renderProxy.js.map +1 -1
- package/dist/renderQueue.js +1 -1
- package/dist/renderQueue.js.map +1 -1
- package/dist/renderTarget.d.ts +7 -7
- package/dist/renderTarget.d.ts.map +1 -1
- package/dist/renderTarget.js +16 -16
- package/dist/renderTarget.js.map +1 -1
- package/dist/sceneRender.d.ts +3 -3
- package/dist/sceneRender.d.ts.map +1 -1
- package/dist/sceneRender.js +27 -23
- package/dist/sceneRender.js.map +1 -1
- package/package.json +12 -12
- package/src/enableColorAdjustmentGuards.test.ts +3 -5
- package/src/{explainDisplayObjectRender.test.ts → explainScene2DRender.test.ts} +21 -21
- package/src/renderAppearance.test.ts +1 -1
- package/src/renderCache.test.ts +1 -1
- package/src/renderColorTransform.test.ts +4 -10
- package/src/renderProxy.test.ts +45 -45
- package/src/renderProxyAdapter.test.ts +1 -1
- package/src/renderQueue.test.ts +7 -7
- package/src/renderTarget.test.ts +32 -32
- package/src/renderTransform2d.test.ts +1 -1
- package/src/renderViewport.test.ts +5 -5
- package/src/renderer.test.ts +2 -2
- package/src/sceneRender.test.ts +76 -62
- package/dist/explainDisplayObjectRender.d.ts +0 -3
- package/dist/explainDisplayObjectRender.d.ts.map +0 -1
- package/dist/explainDisplayObjectRender.js.map +0 -1
package/src/sceneRender.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createCamera3D, createPerspectiveProjection, setCamera3DViewMatrix4FromLookAt } from '@flighthq/camera';
|
|
2
2
|
import { unpackColorToLinear } from '@flighthq/color';
|
|
3
|
-
import { createAabb } from '@flighthq/geometry';
|
|
3
|
+
import { createAabb, createMatrix4 } from '@flighthq/geometry';
|
|
4
4
|
import {
|
|
5
5
|
createAmbientLight,
|
|
6
6
|
createDirectionalLight,
|
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
createBoxMeshGeometry,
|
|
15
15
|
createMeshGeometry,
|
|
16
16
|
} from '@flighthq/mesh';
|
|
17
|
-
import { addNodeChild, getNodeWorldMatrix4, invalidateNodeLocalTransform } from '@flighthq/node';
|
|
18
|
-
import { createMesh,
|
|
19
|
-
import type { Camera3D, Material, MeshGeometry,
|
|
17
|
+
import { addNodeChild, getNodeWorldMatrix4, invalidateNodeLocalTransform, setNodeLocalMatrix4 } from '@flighthq/node';
|
|
18
|
+
import { createMesh, createNode3D, Node3DKind, getNode3DWorldAlpha } from '@flighthq/scene3d';
|
|
19
|
+
import type { Camera3D, Material, MeshGeometry, Scene3DLightBlock, Scene3DLightsLike } from '@flighthq/types';
|
|
20
20
|
import {
|
|
21
21
|
SCENE_LIGHT_BLOCK_FLOATS,
|
|
22
22
|
SCENE_LIGHT_HEMISPHERE_OFFSET,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import { describe, expect, it } from 'vitest';
|
|
27
27
|
|
|
28
28
|
import { createRenderState } from './renderState';
|
|
29
|
-
import {
|
|
29
|
+
import { packScene3DLightBlock, prepareScene3DRender } from './sceneRender';
|
|
30
30
|
|
|
31
31
|
function boundedBox(): MeshGeometry {
|
|
32
32
|
const geometry = createBoxMeshGeometry(2, 2, 2);
|
|
@@ -46,11 +46,11 @@ function frontCamera(): Camera3D {
|
|
|
46
46
|
return camera;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
function emptyLights():
|
|
49
|
+
function emptyLights(): Scene3DLightsLike {
|
|
50
50
|
return { ambient: null, directional: null };
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
function newLightBlock():
|
|
53
|
+
function newLightBlock(): Scene3DLightBlock {
|
|
54
54
|
return {
|
|
55
55
|
ambientCount: 0,
|
|
56
56
|
data: new Float32Array(SCENE_LIGHT_BLOCK_FLOATS),
|
|
@@ -62,11 +62,11 @@ function newLightBlock(): SceneLightBlock {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
describe('
|
|
65
|
+
describe('packScene3DLightBlock', () => {
|
|
66
66
|
it('zeroes the block and clears counts when no lights are present', () => {
|
|
67
67
|
const block = newLightBlock();
|
|
68
68
|
block.data[0] = 5;
|
|
69
|
-
|
|
69
|
+
packScene3DLightBlock(block, emptyLights());
|
|
70
70
|
expect(block.directionalCount).toBe(0);
|
|
71
71
|
expect(block.ambientCount).toBe(0);
|
|
72
72
|
expect(block.data[0]).toBe(0);
|
|
@@ -75,7 +75,7 @@ describe('packSceneLightBlock', () => {
|
|
|
75
75
|
it('packs the directional direction and linear, premultiplied radiance', () => {
|
|
76
76
|
const block = newLightBlock();
|
|
77
77
|
const directional = createDirectionalLight({ color: 0xffffffff, direction: { x: 0, y: -1, z: 0 }, intensity: 2 });
|
|
78
|
-
|
|
78
|
+
packScene3DLightBlock(block, { ambient: null, directional });
|
|
79
79
|
expect(block.directionalCount).toBe(1);
|
|
80
80
|
expect(block.data[0]).toBeCloseTo(0);
|
|
81
81
|
expect(block.data[1]).toBeCloseTo(-1);
|
|
@@ -89,7 +89,7 @@ describe('packSceneLightBlock', () => {
|
|
|
89
89
|
it('packs the ambient radiance into the ambient slot', () => {
|
|
90
90
|
const block = newLightBlock();
|
|
91
91
|
const ambient = createAmbientLight({ color: 0xffffffff, intensity: 0.5 });
|
|
92
|
-
|
|
92
|
+
packScene3DLightBlock(block, { ambient, directional: null });
|
|
93
93
|
expect(block.ambientCount).toBe(1);
|
|
94
94
|
const expected = unpackColorToLinear([0, 0, 0, 0], 0xffffffff);
|
|
95
95
|
expect(block.data[8]).toBeCloseTo(expected[0] * 0.5);
|
|
@@ -99,9 +99,9 @@ describe('packSceneLightBlock', () => {
|
|
|
99
99
|
|
|
100
100
|
it('bumps version when the packed block changes', () => {
|
|
101
101
|
const block = newLightBlock();
|
|
102
|
-
|
|
102
|
+
packScene3DLightBlock(block, emptyLights());
|
|
103
103
|
const v = block.version;
|
|
104
|
-
|
|
104
|
+
packScene3DLightBlock(block, {
|
|
105
105
|
ambient: createAmbientLight({ color: 0xffffffff, intensity: 0.5 }),
|
|
106
106
|
directional: null,
|
|
107
107
|
});
|
|
@@ -111,16 +111,16 @@ describe('packSceneLightBlock', () => {
|
|
|
111
111
|
it('does not bump version when re-packed with identical lights', () => {
|
|
112
112
|
const block = newLightBlock();
|
|
113
113
|
const lights = { ambient: createAmbientLight({ color: 0xffffffff, intensity: 0.5 }), directional: null };
|
|
114
|
-
|
|
114
|
+
packScene3DLightBlock(block, lights);
|
|
115
115
|
const v = block.version;
|
|
116
|
-
|
|
116
|
+
packScene3DLightBlock(block, lights);
|
|
117
117
|
expect(block.version).toBe(v);
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
it('decodes sRgb color to linear (a mid-gray channel is darker in linear)', () => {
|
|
121
121
|
const block = newLightBlock();
|
|
122
122
|
const ambient = createAmbientLight({ color: 0x808080ff, intensity: 1 });
|
|
123
|
-
|
|
123
|
+
packScene3DLightBlock(block, { ambient, directional: null });
|
|
124
124
|
expect(block.data[8]).toBeLessThan(0x80 / 0xff);
|
|
125
125
|
expect(block.data[8]).toBeGreaterThan(0);
|
|
126
126
|
});
|
|
@@ -128,7 +128,7 @@ describe('packSceneLightBlock', () => {
|
|
|
128
128
|
it('packs point lights: position + range, and linear radiance + inverse-square range', () => {
|
|
129
129
|
const block = newLightBlock();
|
|
130
130
|
const point = createPointLight({ color: 0xffffffff, intensity: 3, position: { x: 1, y: 2, z: 3 }, range: 10 });
|
|
131
|
-
|
|
131
|
+
packScene3DLightBlock(block, { ambient: null, directional: null, point: [point] });
|
|
132
132
|
expect(block.pointCount).toBe(1);
|
|
133
133
|
const o = SCENE_LIGHT_POINT_OFFSET;
|
|
134
134
|
expect(block.data[o + 0]).toBeCloseTo(1);
|
|
@@ -143,7 +143,7 @@ describe('packSceneLightBlock', () => {
|
|
|
143
143
|
it('packs an infinite-range point light with invSqrRange 0 (no cutoff)', () => {
|
|
144
144
|
const block = newLightBlock();
|
|
145
145
|
const point = createPointLight({ range: -1 });
|
|
146
|
-
|
|
146
|
+
packScene3DLightBlock(block, { ambient: null, directional: null, point: [point] });
|
|
147
147
|
expect(block.data[SCENE_LIGHT_POINT_OFFSET + 3]).toBeCloseTo(-1);
|
|
148
148
|
expect(block.data[SCENE_LIGHT_POINT_OFFSET + 7]).toBe(0);
|
|
149
149
|
});
|
|
@@ -156,7 +156,7 @@ describe('packSceneLightBlock', () => {
|
|
|
156
156
|
outerConeDegrees: 30,
|
|
157
157
|
position: { x: 4, y: 5, z: 6 },
|
|
158
158
|
});
|
|
159
|
-
|
|
159
|
+
packScene3DLightBlock(block, { ambient: null, directional: null, spot: [spot] });
|
|
160
160
|
expect(block.spotCount).toBe(1);
|
|
161
161
|
const o = SCENE_LIGHT_SPOT_OFFSET;
|
|
162
162
|
expect(block.data[o + 0]).toBeCloseTo(4);
|
|
@@ -172,7 +172,7 @@ describe('packSceneLightBlock', () => {
|
|
|
172
172
|
it('packs hemisphere lights: sky, ground, and packed world-up', () => {
|
|
173
173
|
const block = newLightBlock();
|
|
174
174
|
const hemisphere = createHemisphereLight({ groundColor: 0x000000ff, intensity: 2, skyColor: 0xffffffff });
|
|
175
|
-
|
|
175
|
+
packScene3DLightBlock(block, { ambient: null, directional: null, hemisphere: [hemisphere] });
|
|
176
176
|
expect(block.hemisphereCount).toBe(1);
|
|
177
177
|
const o = SCENE_LIGHT_HEMISPHERE_OFFSET;
|
|
178
178
|
const sky = unpackColorToLinear([0, 0, 0, 0], 0xffffffff);
|
|
@@ -187,13 +187,13 @@ describe('packSceneLightBlock', () => {
|
|
|
187
187
|
it('caps each punctual array at MAX_FORWARD_LIGHTS', () => {
|
|
188
188
|
const block = newLightBlock();
|
|
189
189
|
const many = Array.from({ length: 9 }, () => createPointLight());
|
|
190
|
-
|
|
190
|
+
packScene3DLightBlock(block, { ambient: null, directional: null, point: many });
|
|
191
191
|
expect(block.pointCount).toBe(4);
|
|
192
192
|
});
|
|
193
193
|
|
|
194
194
|
it('reports zero counts for empty punctual arrays', () => {
|
|
195
195
|
const block = newLightBlock();
|
|
196
|
-
|
|
196
|
+
packScene3DLightBlock(block, { ambient: null, directional: null, hemisphere: [], point: [], spot: [] });
|
|
197
197
|
expect(block.pointCount).toBe(0);
|
|
198
198
|
expect(block.spotCount).toBe(0);
|
|
199
199
|
expect(block.hemisphereCount).toBe(0);
|
|
@@ -202,21 +202,21 @@ describe('packSceneLightBlock', () => {
|
|
|
202
202
|
it('does not bump version when re-packed with identical punctual lights', () => {
|
|
203
203
|
const block = newLightBlock();
|
|
204
204
|
const lights = { ambient: null, directional: null, point: [createPointLight({ range: 5 })] };
|
|
205
|
-
|
|
205
|
+
packScene3DLightBlock(block, lights);
|
|
206
206
|
const v = block.version;
|
|
207
|
-
|
|
207
|
+
packScene3DLightBlock(block, lights);
|
|
208
208
|
expect(block.version).toBe(v);
|
|
209
209
|
});
|
|
210
210
|
});
|
|
211
211
|
|
|
212
|
-
describe('
|
|
212
|
+
describe('prepareScene3DRender', () => {
|
|
213
213
|
it('returns the lit, view-projected frame with the visible mesh', () => {
|
|
214
214
|
const state = createRenderState();
|
|
215
|
-
const scene =
|
|
215
|
+
const scene = createNode3D(Node3DKind);
|
|
216
216
|
const mesh = createMesh(boundedBox(), [null]);
|
|
217
217
|
addNodeChild(scene, mesh);
|
|
218
218
|
|
|
219
|
-
const list =
|
|
219
|
+
const list = prepareScene3DRender(state, scene, frontCamera(), {
|
|
220
220
|
ambient: createAmbientLight(),
|
|
221
221
|
directional: createDirectionalLight(),
|
|
222
222
|
});
|
|
@@ -229,21 +229,21 @@ describe('prepareSceneRender', () => {
|
|
|
229
229
|
|
|
230
230
|
it('computes a non-identity view-projection', () => {
|
|
231
231
|
const state = createRenderState();
|
|
232
|
-
const scene =
|
|
233
|
-
const list =
|
|
232
|
+
const scene = createNode3D(Node3DKind);
|
|
233
|
+
const list = prepareScene3DRender(state, scene, frontCamera(), emptyLights());
|
|
234
234
|
// A perspective view-projection is not the identity matrix.
|
|
235
235
|
expect(list.viewProjection.m[15]).not.toBe(1);
|
|
236
236
|
});
|
|
237
237
|
|
|
238
238
|
it('culls a mesh placed far behind the camera', () => {
|
|
239
239
|
const state = createRenderState();
|
|
240
|
-
const scene =
|
|
240
|
+
const scene = createNode3D(Node3DKind);
|
|
241
241
|
const mesh = createMesh(boundedBox(), [null]);
|
|
242
242
|
mesh.position.z = 1000;
|
|
243
243
|
invalidateNodeLocalTransform(mesh);
|
|
244
244
|
addNodeChild(scene, mesh);
|
|
245
245
|
|
|
246
|
-
const list =
|
|
246
|
+
const list = prepareScene3DRender(state, scene, frontCamera(), emptyLights());
|
|
247
247
|
expect(list.meshCount).toBe(0);
|
|
248
248
|
});
|
|
249
249
|
|
|
@@ -251,14 +251,14 @@ describe('prepareSceneRender', () => {
|
|
|
251
251
|
// A null bounds cache is uncomputed, not uncullable: the cull ensures the bounds (the box has
|
|
252
252
|
// vertices) and then culls a far-off box normally, rather than conservatively keeping it.
|
|
253
253
|
const state = createRenderState();
|
|
254
|
-
const scene =
|
|
254
|
+
const scene = createNode3D(Node3DKind);
|
|
255
255
|
const mesh = createMesh(createBoxMeshGeometry(2, 2, 2), [null]);
|
|
256
256
|
mesh.geometry.bounds = null;
|
|
257
257
|
mesh.position.z = 1000;
|
|
258
258
|
invalidateNodeLocalTransform(mesh);
|
|
259
259
|
addNodeChild(scene, mesh);
|
|
260
260
|
|
|
261
|
-
const list =
|
|
261
|
+
const list = prepareScene3DRender(state, scene, frontCamera(), emptyLights());
|
|
262
262
|
expect(list.meshCount).toBe(0);
|
|
263
263
|
});
|
|
264
264
|
|
|
@@ -266,61 +266,61 @@ describe('prepareSceneRender', () => {
|
|
|
266
266
|
// Truly unbounded geometry (no vertices) is the only case ensureMeshGeometryBounds returns null
|
|
267
267
|
// for, and it is what "cannot cull, so conservatively keep" now means.
|
|
268
268
|
const state = createRenderState();
|
|
269
|
-
const scene =
|
|
269
|
+
const scene = createNode3D(Node3DKind);
|
|
270
270
|
const empty = createMeshGeometry({ layout: CANONICAL_MESH_GEOMETRY_LAYOUT, vertices: new Float32Array(0) });
|
|
271
271
|
const mesh = createMesh(empty, [null]);
|
|
272
272
|
mesh.position.z = 1000;
|
|
273
273
|
invalidateNodeLocalTransform(mesh);
|
|
274
274
|
addNodeChild(scene, mesh);
|
|
275
275
|
|
|
276
|
-
const list =
|
|
276
|
+
const list = prepareScene3DRender(state, scene, frontCamera(), emptyLights());
|
|
277
277
|
expect(list.meshCount).toBe(1);
|
|
278
278
|
});
|
|
279
279
|
|
|
280
280
|
it('skips disabled subtrees', () => {
|
|
281
281
|
const state = createRenderState();
|
|
282
|
-
const scene =
|
|
283
|
-
const group =
|
|
282
|
+
const scene = createNode3D(Node3DKind);
|
|
283
|
+
const group = createNode3D(Node3DKind, { enabled: false });
|
|
284
284
|
const mesh = createMesh(boundedBox(), [null]);
|
|
285
285
|
addNodeChild(group, mesh);
|
|
286
286
|
addNodeChild(scene, group);
|
|
287
287
|
|
|
288
|
-
const list =
|
|
288
|
+
const list = prepareScene3DRender(state, scene, frontCamera(), emptyLights());
|
|
289
289
|
expect(list.meshCount).toBe(0);
|
|
290
290
|
});
|
|
291
291
|
|
|
292
292
|
it('skips a hidden subtree (visible=false propagates to descendants)', () => {
|
|
293
293
|
const state = createRenderState();
|
|
294
|
-
const scene =
|
|
295
|
-
const group =
|
|
294
|
+
const scene = createNode3D(Node3DKind);
|
|
295
|
+
const group = createNode3D(Node3DKind);
|
|
296
296
|
group.visible = false;
|
|
297
297
|
const mesh = createMesh(boundedBox(), [null]);
|
|
298
298
|
addNodeChild(group, mesh);
|
|
299
299
|
addNodeChild(scene, group);
|
|
300
300
|
|
|
301
|
-
const list =
|
|
301
|
+
const list = prepareScene3DRender(state, scene, frontCamera(), emptyLights());
|
|
302
302
|
expect(list.meshCount).toBe(0);
|
|
303
303
|
});
|
|
304
304
|
|
|
305
305
|
it('resolves world transforms through nested groups', () => {
|
|
306
306
|
const state = createRenderState();
|
|
307
|
-
const scene =
|
|
308
|
-
const group =
|
|
307
|
+
const scene = createNode3D(Node3DKind);
|
|
308
|
+
const group = createNode3D(Node3DKind);
|
|
309
309
|
const mesh = createMesh(boundedBox(), [null]);
|
|
310
310
|
addNodeChild(group, mesh);
|
|
311
311
|
addNodeChild(scene, group);
|
|
312
312
|
group.position.x = 1;
|
|
313
313
|
invalidateNodeLocalTransform(group);
|
|
314
314
|
|
|
315
|
-
const list =
|
|
315
|
+
const list = prepareScene3DRender(state, scene, frontCamera(), emptyLights());
|
|
316
316
|
expect(list.meshCount).toBe(1);
|
|
317
317
|
expect(list.visibleMeshes[0]).toBe(mesh);
|
|
318
318
|
});
|
|
319
319
|
|
|
320
320
|
it('folds parent x self alpha into each node resolved worldAlpha', () => {
|
|
321
321
|
const state = createRenderState();
|
|
322
|
-
const scene =
|
|
323
|
-
const group =
|
|
322
|
+
const scene = createNode3D(Node3DKind);
|
|
323
|
+
const group = createNode3D(Node3DKind);
|
|
324
324
|
const mesh = createMesh(boundedBox(), [null]);
|
|
325
325
|
addNodeChild(group, mesh);
|
|
326
326
|
addNodeChild(scene, group);
|
|
@@ -328,54 +328,68 @@ describe('prepareSceneRender', () => {
|
|
|
328
328
|
group.alpha = 0.5;
|
|
329
329
|
mesh.alpha = 0.5;
|
|
330
330
|
|
|
331
|
-
|
|
332
|
-
expect(
|
|
333
|
-
expect(
|
|
334
|
-
expect(
|
|
331
|
+
prepareScene3DRender(state, scene, frontCamera(), emptyLights());
|
|
332
|
+
expect(getNode3DWorldAlpha(scene)).toBeCloseTo(0.5);
|
|
333
|
+
expect(getNode3DWorldAlpha(group)).toBeCloseTo(0.25);
|
|
334
|
+
expect(getNode3DWorldAlpha(mesh)).toBeCloseTo(0.125);
|
|
335
335
|
});
|
|
336
336
|
|
|
337
337
|
it('reuses the same list per render state across calls', () => {
|
|
338
338
|
const state = createRenderState();
|
|
339
|
-
const scene =
|
|
340
|
-
const first =
|
|
341
|
-
const second =
|
|
339
|
+
const scene = createNode3D(Node3DKind);
|
|
340
|
+
const first = prepareScene3DRender(state, scene, frontCamera(), emptyLights());
|
|
341
|
+
const second = prepareScene3DRender(state, scene, frontCamera(), emptyLights());
|
|
342
342
|
expect(second).toBe(first);
|
|
343
343
|
});
|
|
344
344
|
|
|
345
345
|
it('honors a positional material on a mesh', () => {
|
|
346
346
|
const state = createRenderState();
|
|
347
|
-
const scene =
|
|
347
|
+
const scene = createNode3D(Node3DKind);
|
|
348
348
|
const material = { kind: 'TestMaterial' } as unknown as Material;
|
|
349
349
|
const mesh = createMesh(boundedBox(), [material]);
|
|
350
350
|
addNodeChild(scene, mesh);
|
|
351
|
-
const list =
|
|
351
|
+
const list = prepareScene3DRender(state, scene, frontCamera(), emptyLights());
|
|
352
352
|
expect(list.visibleMeshes[0].materials[0]).toBe(material);
|
|
353
353
|
});
|
|
354
354
|
|
|
355
355
|
it('refreshes a mesh world transform under the default policy without an explicit invalidate', () => {
|
|
356
356
|
const state = createRenderState(); // default 'refreshDerivedState'
|
|
357
|
-
const scene =
|
|
357
|
+
const scene = createNode3D(Node3DKind);
|
|
358
358
|
const mesh = createMesh(boundedBox(), [null]);
|
|
359
359
|
addNodeChild(scene, mesh);
|
|
360
360
|
const camera = frontCamera();
|
|
361
|
-
|
|
361
|
+
prepareScene3DRender(state, scene, camera, emptyLights());
|
|
362
362
|
mesh.position.x = 3; // bare mutation, no invalidateNodeLocalTransform
|
|
363
|
-
|
|
363
|
+
prepareScene3DRender(state, scene, camera, emptyLights());
|
|
364
|
+
expect(getNodeWorldMatrix4(mesh).m[12]).toBeCloseTo(3);
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
it('preserves a directly-authored local matrix under the default refresh policy', () => {
|
|
368
|
+
const state = createRenderState();
|
|
369
|
+
const scene = createNode3D(Node3DKind);
|
|
370
|
+
const mesh = createMesh(boundedBox(), [null]);
|
|
371
|
+
addNodeChild(scene, mesh);
|
|
372
|
+
const local = createMatrix4();
|
|
373
|
+
local.m[12] = 3;
|
|
374
|
+
setNodeLocalMatrix4(mesh, local);
|
|
375
|
+
|
|
376
|
+
prepareScene3DRender(state, scene, frontCamera(), emptyLights());
|
|
377
|
+
|
|
364
378
|
expect(getNodeWorldMatrix4(mesh).m[12]).toBeCloseTo(3);
|
|
365
379
|
});
|
|
366
380
|
|
|
367
381
|
it('leaves a mesh world transform stale under requiresInvalidation until invalidated', () => {
|
|
368
382
|
const state = createRenderState({ sceneGraphSyncPolicy: 'requiresInvalidation' });
|
|
369
|
-
const scene =
|
|
383
|
+
const scene = createNode3D(Node3DKind);
|
|
370
384
|
const mesh = createMesh(boundedBox(), [null]);
|
|
371
385
|
addNodeChild(scene, mesh);
|
|
372
386
|
const camera = frontCamera();
|
|
373
|
-
|
|
387
|
+
prepareScene3DRender(state, scene, camera, emptyLights());
|
|
374
388
|
mesh.position.x = 3;
|
|
375
|
-
|
|
389
|
+
prepareScene3DRender(state, scene, camera, emptyLights());
|
|
376
390
|
expect(getNodeWorldMatrix4(mesh).m[12]).toBeCloseTo(0); // stale: the caller never invalidated
|
|
377
391
|
invalidateNodeLocalTransform(mesh);
|
|
378
|
-
|
|
392
|
+
prepareScene3DRender(state, scene, camera, emptyLights());
|
|
379
393
|
expect(getNodeWorldMatrix4(mesh).m[12]).toBeCloseTo(3);
|
|
380
394
|
});
|
|
381
395
|
});
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { DisplayObjectRenderExplanation, Renderable, RenderState } from '@flighthq/types';
|
|
2
|
-
export declare function explainDisplayObjectRender(state: RenderState, source: Renderable): DisplayObjectRenderExplanation;
|
|
3
|
-
//# sourceMappingURL=explainDisplayObjectRender.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"explainDisplayObjectRender.d.ts","sourceRoot":"","sources":["../src/explainDisplayObjectRender.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,8BAA8B,EAE9B,UAAU,EACV,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAqBzB,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,8BAA8B,CAmBjH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"explainDisplayObjectRender.js","sourceRoot":"","sources":["../src/explainDisplayObjectRender.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,uGAAuG;AACvG,qGAAqG;AACrG,oGAAoG;AACpG,uFAAuF;AACvF,EAAE;AACF,oGAAoG;AACpG,gGAAgG;AAChG,kGAAkG;AAClG,uGAAuG;AACvG,6FAA6F;AAC7F,yFAAyF;AACzF,EAAE;AACF,sGAAsG;AACtG,kGAAkG;AAClG,uGAAuG;AACvG,iGAAiG;AACjG,MAAM,UAAU,0BAA0B,CAAC,KAAkB,EAAE,MAAkB;IAC/E,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,MAAM,WAAW,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;IAErF,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC9C,MAAM,QAAQ,GAAG,KAAK,KAAK,SAAS,CAAC;IAErC,MAAM,UAAU,GAAG,MAAkC,CAAC;IACtD,MAAM,OAAO,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC;IACzE,MAAM,cAAc,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;IAE5E,IAAI,MAAsC,CAAC;IAC3C,IAAI,CAAC,WAAW;QAAE,MAAM,GAAG,aAAa,CAAC;SACpC,IAAI,CAAC,QAAQ;QAAE,MAAM,GAAG,cAAc,CAAC;SACvC,IAAI,CAAC,OAAO;QAAE,MAAM,GAAG,aAAa,CAAC;SACrC,IAAI,cAAc,IAAI,CAAC;QAAE,MAAM,GAAG,YAAY,CAAC;;QAC/C,MAAM,GAAG,IAAI,CAAC;IAEnB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;AAC1E,CAAC"}
|