@woosh/meep-engine 2.109.4 → 2.109.6
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/build/meep.cjs +115 -17
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +115 -17
- package/package.json +1 -1
- package/src/core/collection/queue/Deque.d.ts.map +1 -1
- package/src/core/collection/queue/Deque.js +58 -4
- package/src/core/collection/queue/Deque.spec.js +29 -0
- package/src/core/geom/3d/Ray3.d.ts +23 -10
- package/src/core/geom/3d/Ray3.d.ts.map +1 -1
- package/src/core/geom/3d/Ray3.js +59 -20
- package/src/core/geom/3d/ray/ray3_interval_array_apply_matrix4.d.ts +2 -2
- package/src/core/geom/3d/ray/ray3_interval_array_apply_matrix4.d.ts.map +1 -1
- package/src/core/geom/3d/ray/ray3_interval_array_apply_matrix4.js +42 -27
- package/src/core/geom/3d/tetrahedra/triangle/prototype.js +0 -2
- package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.js +5 -2
- package/src/core/geom/vec3/v3_matrix4_rotate.d.ts +10 -0
- package/src/core/geom/vec3/v3_matrix4_rotate.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_matrix4_rotate.js +27 -0
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +1 -0
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +5 -3
- package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/sh3_bake_depth.js +2 -1
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts +9 -4
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +61 -6
- package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.d.ts +11 -4
- package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +28 -36
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts +17 -8
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +83 -44
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts +3 -3
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +40 -33
- package/src/engine/graphics/sh3/path_tracer/material/MaterialConverter.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/material/MaterialConverter.js +43 -40
- package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.d.ts +14 -0
- package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.js +34 -1
- package/src/engine/graphics/sh3/path_tracer/prepare_scene_gltf.d.ts +21 -0
- package/src/engine/graphics/sh3/path_tracer/prepare_scene_gltf.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/prepare_scene_gltf.js +107 -0
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +22 -122
- package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.d.ts +0 -9
- package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.js +2 -28
- package/src/engine/graphics/sh3/path_tracer/sampling/getBiasedNormalSample.d.ts +0 -9
- package/src/engine/graphics/sh3/path_tracer/sampling/getBiasedNormalSample.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/sampling/getBiasedNormalSample.js +0 -39
- package/src/engine/graphics/sh3/path_tracer/sampling/getCosineDirection.d.ts +10 -0
- package/src/engine/graphics/sh3/path_tracer/sampling/getCosineDirection.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/sampling/getCosineDirection.js +41 -0
- package/src/engine/graphics/sh3/path_tracer/sampling/v3_orthonormal_matrix_from_normal.d.ts +10 -0
- package/src/engine/graphics/sh3/path_tracer/sampling/v3_orthonormal_matrix_from_normal.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/sampling/v3_orthonormal_matrix_from_normal.js +45 -0
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +28 -8
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +7 -5
- package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +62 -13
- package/src/engine/graphics/texture/virtual/prototype.js +4 -3
- package/src/engine/graphics/three/material/iterate_three_material_textures.d.ts +10 -0
- package/src/engine/graphics/three/material/iterate_three_material_textures.d.ts.map +1 -0
- package/src/engine/graphics/three/material/iterate_three_material_textures.js +33 -0
- package/src/core/math/max4.d.ts +0 -10
- package/src/core/math/max4.d.ts.map +0 -1
- package/src/core/math/max4.js +0 -24
- package/src/core/math/min4.d.ts +0 -10
- package/src/core/math/min4.d.ts.map +0 -1
- package/src/core/math/min4.js +0 -23
package/build/meep.module.js
CHANGED
|
@@ -67733,6 +67733,60 @@ function sampler2d_ensure_uint8_RGBA(input) {
|
|
|
67733
67733
|
const DEFAULT_TEXTURE_WIDTH = 512;
|
|
67734
67734
|
const DEFAULT_TEXTURE_HEIGHT = 512;
|
|
67735
67735
|
|
|
67736
|
+
/**
|
|
67737
|
+
*
|
|
67738
|
+
* @param {THREE.DataTexture} texture
|
|
67739
|
+
* @param {number} channel_count
|
|
67740
|
+
* @param {number} _width
|
|
67741
|
+
* @param {number} _height
|
|
67742
|
+
* @returns {Sampler2D}
|
|
67743
|
+
*/
|
|
67744
|
+
function data_texture_to_sampler(texture, channel_count, _width, _height) {
|
|
67745
|
+
const source = new Sampler2D(texture.image.data, channel_count, texture.image.width, texture.image.height);
|
|
67746
|
+
|
|
67747
|
+
let converted = sampler2d_ensure_uint8_RGBA(source);
|
|
67748
|
+
|
|
67749
|
+
if (converted.width !== _width || converted.height !== _height) {
|
|
67750
|
+
const target = Sampler2D.uint8(4, _width, _height);
|
|
67751
|
+
|
|
67752
|
+
sampler2d_scale(converted, target);
|
|
67753
|
+
|
|
67754
|
+
converted = target;
|
|
67755
|
+
}
|
|
67756
|
+
return converted;
|
|
67757
|
+
}
|
|
67758
|
+
|
|
67759
|
+
/**
|
|
67760
|
+
*
|
|
67761
|
+
* @param {THREE.Texture} texture
|
|
67762
|
+
* @param {number} channel_count
|
|
67763
|
+
* @param {number} _width
|
|
67764
|
+
* @param {number} _height
|
|
67765
|
+
* @returns {Sampler2D}
|
|
67766
|
+
*/
|
|
67767
|
+
function html_image_texture_to_sampler(texture, channel_count, _width, _height) {
|
|
67768
|
+
/**
|
|
67769
|
+
*
|
|
67770
|
+
* @type {Image}
|
|
67771
|
+
*/
|
|
67772
|
+
const img = texture.image;
|
|
67773
|
+
|
|
67774
|
+
const canvas = document.createElement('canvas');
|
|
67775
|
+
|
|
67776
|
+
canvas.width = _width;
|
|
67777
|
+
canvas.height = _height;
|
|
67778
|
+
|
|
67779
|
+
const ctx = canvas.getContext('2d');
|
|
67780
|
+
|
|
67781
|
+
ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, _width, _height);
|
|
67782
|
+
|
|
67783
|
+
const result = Sampler2D.uint8(4, _width, _height);
|
|
67784
|
+
|
|
67785
|
+
canvasDataToSampler(result, ctx);
|
|
67786
|
+
|
|
67787
|
+
return result;
|
|
67788
|
+
}
|
|
67789
|
+
|
|
67736
67790
|
/**
|
|
67737
67791
|
*
|
|
67738
67792
|
* @param {Texture} texture
|
|
@@ -67752,8 +67806,6 @@ function convertTexture2Sampler2D(
|
|
|
67752
67806
|
|
|
67753
67807
|
const channel_count = formatToChannelCount(texture.format);
|
|
67754
67808
|
|
|
67755
|
-
// TODO take channel count into account
|
|
67756
|
-
|
|
67757
67809
|
if (_width === undefined || _height === undefined) {
|
|
67758
67810
|
|
|
67759
67811
|
//figure out texture size
|
|
@@ -67792,21 +67844,14 @@ function convertTexture2Sampler2D(
|
|
|
67792
67844
|
if (texture.isDataTexture === true) {
|
|
67793
67845
|
|
|
67794
67846
|
// special case
|
|
67847
|
+
const converted = data_texture_to_sampler(texture, channel_count, _width, _height);
|
|
67795
67848
|
|
|
67796
|
-
|
|
67797
|
-
|
|
67798
|
-
let converted = sampler2d_ensure_uint8_RGBA(source);
|
|
67799
|
-
|
|
67800
|
-
if (converted.width !== _width || converted.height !== _height) {
|
|
67801
|
-
const target = Sampler2D.uint8(4, _width, _height);
|
|
67849
|
+
data = converted.data;
|
|
67802
67850
|
|
|
67803
|
-
|
|
67804
|
-
|
|
67805
|
-
converted = target;
|
|
67806
|
-
}
|
|
67851
|
+
} else if (texture.image instanceof Image) {
|
|
67852
|
+
const converted = html_image_texture_to_sampler(texture, channel_count, _width, _height);
|
|
67807
67853
|
|
|
67808
67854
|
data = converted.data;
|
|
67809
|
-
|
|
67810
67855
|
} else {
|
|
67811
67856
|
const built = WebGLRendererPool.global.use(renderer => {
|
|
67812
67857
|
|
|
@@ -84850,7 +84895,7 @@ class Deque {
|
|
|
84850
84895
|
* @type {T[]}
|
|
84851
84896
|
* @private
|
|
84852
84897
|
*/
|
|
84853
|
-
#data=EMPTY_ARRAY;
|
|
84898
|
+
#data = EMPTY_ARRAY;
|
|
84854
84899
|
/**
|
|
84855
84900
|
*
|
|
84856
84901
|
* @type {number}
|
|
@@ -84940,8 +84985,8 @@ class Deque {
|
|
|
84940
84985
|
|
|
84941
84986
|
let new_length = length * 2;
|
|
84942
84987
|
|
|
84943
|
-
// bigger than Integer.MAX_VALUE
|
|
84944
84988
|
if (new_length > UINT32_MAX) {
|
|
84989
|
+
// clamp to max uint32 value
|
|
84945
84990
|
new_length = UINT32_MAX;
|
|
84946
84991
|
}
|
|
84947
84992
|
|
|
@@ -84971,7 +85016,7 @@ class Deque {
|
|
|
84971
85016
|
* @return {boolean}
|
|
84972
85017
|
*/
|
|
84973
85018
|
isEmpty() {
|
|
84974
|
-
return this
|
|
85019
|
+
return this.#status === STATUS_EMPTY;
|
|
84975
85020
|
}
|
|
84976
85021
|
|
|
84977
85022
|
clear() {
|
|
@@ -85080,9 +85125,10 @@ class Deque {
|
|
|
85080
85125
|
|
|
85081
85126
|
const data = this.#data;
|
|
85082
85127
|
const capacity = data.length;
|
|
85128
|
+
const head = this.#head;
|
|
85083
85129
|
|
|
85084
85130
|
for (let i = 0; i < size; i++) {
|
|
85085
|
-
const index = (
|
|
85131
|
+
const index = (head + i) % capacity;
|
|
85086
85132
|
|
|
85087
85133
|
const el = data[index];
|
|
85088
85134
|
|
|
@@ -85167,6 +85213,58 @@ class Deque {
|
|
|
85167
85213
|
const last = this.#circular_previous_position(this.#tail);
|
|
85168
85214
|
return this.#data[last];
|
|
85169
85215
|
}
|
|
85216
|
+
|
|
85217
|
+
/**
|
|
85218
|
+
* Retrieved element by position from head. Where element at the head is position 0
|
|
85219
|
+
* @param {number} index
|
|
85220
|
+
* @returns {T|undefined} undefined if indexing element that is past the end, otherwise returns element at the position given
|
|
85221
|
+
*/
|
|
85222
|
+
getElementByIndex(index) {
|
|
85223
|
+
|
|
85224
|
+
if (index >= this.size()) {
|
|
85225
|
+
// overflow
|
|
85226
|
+
return undefined;
|
|
85227
|
+
}
|
|
85228
|
+
|
|
85229
|
+
const data = this.#data;
|
|
85230
|
+
|
|
85231
|
+
/**
|
|
85232
|
+
*
|
|
85233
|
+
* @type {number}
|
|
85234
|
+
*/
|
|
85235
|
+
const position = (this.#head + index) % data.length;
|
|
85236
|
+
|
|
85237
|
+
return data[position];
|
|
85238
|
+
}
|
|
85239
|
+
|
|
85240
|
+
/**
|
|
85241
|
+
* Returns a copy of this queue represented as an array without gaps, with the head of the queue (first element) being at position 0
|
|
85242
|
+
* @param {T[]} [result]
|
|
85243
|
+
* @param {number} [result_offset]
|
|
85244
|
+
* @returns {T[]}
|
|
85245
|
+
*/
|
|
85246
|
+
toArray(result = [], result_offset = 0) {
|
|
85247
|
+
const size = this.size();
|
|
85248
|
+
|
|
85249
|
+
for (let i = 0; i < size; i++) {
|
|
85250
|
+
result[i] = this.getElementByIndex(i);
|
|
85251
|
+
}
|
|
85252
|
+
|
|
85253
|
+
return result;
|
|
85254
|
+
}
|
|
85255
|
+
|
|
85256
|
+
/**
|
|
85257
|
+
*
|
|
85258
|
+
* @returns {Generator<T,void>}
|
|
85259
|
+
*/
|
|
85260
|
+
* [Symbol.iterator]() {
|
|
85261
|
+
|
|
85262
|
+
const size = this.size();
|
|
85263
|
+
|
|
85264
|
+
for (let i = 0; i < size; i++) {
|
|
85265
|
+
yield this.getElementByIndex(i);
|
|
85266
|
+
}
|
|
85267
|
+
}
|
|
85170
85268
|
}
|
|
85171
85269
|
|
|
85172
85270
|
/*
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Deque.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/queue/Deque.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH;IA8BI;;;OAGG;IACH,uBAFW,MAAM,EAUhB;IAqFD;;;OAGG;IACH,WAFY,OAAO,CAIlB;IAED,cAeC;IAED;;OAEG;IACH,QAFa,MAAM,CAalB;IA+CD;;;;OAIG;IACH,UAHW,CAAC,GACC,OAAO,CAYnB;
|
|
1
|
+
{"version":3,"file":"Deque.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/queue/Deque.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH;IA8BI;;;OAGG;IACH,uBAFW,MAAM,EAUhB;IAqFD;;;OAGG;IACH,WAFY,OAAO,CAIlB;IAED,cAeC;IAED;;OAEG;IACH,QAFa,MAAM,CAalB;IA+CD;;;;OAIG;IACH,UAHW,CAAC,GACC,OAAO,CAYnB;IA4BD;;;;OAIG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,YAFW,CAAC,QAOX;IAED;;;OAGG;IACH,eAFa,CAAC,GAAC,SAAS,CAQvB;IAED;;;OAGG;IACH,YAFa,CAAC,GAAC,SAAS,CAIvB;IAED;;;OAGG;IACH,WAFW,CAAC,QAOX;IAED;;;OAGG;IACH,cAFa,CAAC,CASb;IAGD;;;OAGG;IACH,WAFa,CAAC,GAAC,SAAS,CAKvB;IAED;;;;OAIG;IACH,yBAHW,MAAM,GACJ,CAAC,GAAC,SAAS,CAmBvB;IAED;;;;;OAKG;IACH,iBAJW,CAAC,EAAE,kBACH,MAAM,GACJ,CAAC,EAAE,CAUf;IAoBL,gBAAoB;IACpB,uBAAoB;IACpB,eAAmB;IAEnB;;OAEG;IACH,sBAAmB;IAzBf;;;OAGG;IACH,qBAFa,UAAU,CAAC,EAAC,IAAI,CAAC,CAS7B;;CACJ"}
|
|
@@ -25,7 +25,7 @@ export class Deque {
|
|
|
25
25
|
* @type {T[]}
|
|
26
26
|
* @private
|
|
27
27
|
*/
|
|
28
|
-
#data=EMPTY_ARRAY;
|
|
28
|
+
#data = EMPTY_ARRAY;
|
|
29
29
|
/**
|
|
30
30
|
*
|
|
31
31
|
* @type {number}
|
|
@@ -117,8 +117,8 @@ export class Deque {
|
|
|
117
117
|
|
|
118
118
|
let new_length = length * 2;
|
|
119
119
|
|
|
120
|
-
// bigger than Integer.MAX_VALUE
|
|
121
120
|
if (new_length > UINT32_MAX) {
|
|
121
|
+
// clamp to max uint32 value
|
|
122
122
|
new_length = UINT32_MAX;
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -148,7 +148,7 @@ export class Deque {
|
|
|
148
148
|
* @return {boolean}
|
|
149
149
|
*/
|
|
150
150
|
isEmpty() {
|
|
151
|
-
return this
|
|
151
|
+
return this.#status === STATUS_EMPTY;
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
clear() {
|
|
@@ -257,9 +257,10 @@ export class Deque {
|
|
|
257
257
|
|
|
258
258
|
const data = this.#data;
|
|
259
259
|
const capacity = data.length;
|
|
260
|
+
const head = this.#head;
|
|
260
261
|
|
|
261
262
|
for (let i = 0; i < size; i++) {
|
|
262
|
-
const index = (
|
|
263
|
+
const index = (head + i) % capacity;
|
|
263
264
|
|
|
264
265
|
const el = data[index];
|
|
265
266
|
|
|
@@ -344,6 +345,59 @@ export class Deque {
|
|
|
344
345
|
const last = this.#circular_previous_position(this.#tail);
|
|
345
346
|
return this.#data[last];
|
|
346
347
|
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Retrieved element by position from head. Where element at the head is position 0
|
|
351
|
+
* @param {number} index
|
|
352
|
+
* @returns {T|undefined} undefined if indexing element that is past the end, otherwise returns element at the position given
|
|
353
|
+
*/
|
|
354
|
+
getElementByIndex(index) {
|
|
355
|
+
assert.isNonNegativeInteger(index, 'index');
|
|
356
|
+
|
|
357
|
+
if (index >= this.size()) {
|
|
358
|
+
// overflow
|
|
359
|
+
return undefined;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const data = this.#data;
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
*
|
|
366
|
+
* @type {number}
|
|
367
|
+
*/
|
|
368
|
+
const position = (this.#head + index) % data.length;
|
|
369
|
+
|
|
370
|
+
return data[position];
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Returns a copy of this queue represented as an array without gaps, with the head of the queue (first element) being at position 0
|
|
375
|
+
* @param {T[]} [result]
|
|
376
|
+
* @param {number} [result_offset]
|
|
377
|
+
* @returns {T[]}
|
|
378
|
+
*/
|
|
379
|
+
toArray(result = [], result_offset = 0) {
|
|
380
|
+
const size = this.size();
|
|
381
|
+
|
|
382
|
+
for (let i = 0; i < size; i++) {
|
|
383
|
+
result[i] = this.getElementByIndex(i);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
return result;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
*
|
|
391
|
+
* @returns {Generator<T,void>}
|
|
392
|
+
*/
|
|
393
|
+
* [Symbol.iterator]() {
|
|
394
|
+
|
|
395
|
+
const size = this.size();
|
|
396
|
+
|
|
397
|
+
for (let i = 0; i < size; i++) {
|
|
398
|
+
yield this.getElementByIndex(i);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
347
401
|
}
|
|
348
402
|
|
|
349
403
|
/*
|
|
@@ -245,3 +245,32 @@ test("fill queue beyond default size and then drain it", () => {
|
|
|
245
245
|
expect(queue.pop()).toBe(3);
|
|
246
246
|
expect(queue.size()).toBe(0);
|
|
247
247
|
});
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
test("toArray", () => {
|
|
251
|
+
|
|
252
|
+
const q = new Deque(2);
|
|
253
|
+
|
|
254
|
+
expect(q.toArray()).toEqual([]);
|
|
255
|
+
|
|
256
|
+
q.addLast(1);
|
|
257
|
+
|
|
258
|
+
expect(q.toArray()).toEqual([1]);
|
|
259
|
+
|
|
260
|
+
q.addLast(7);
|
|
261
|
+
|
|
262
|
+
expect(q.toArray()).toEqual([1, 7]);
|
|
263
|
+
|
|
264
|
+
q.removeFirst();
|
|
265
|
+
|
|
266
|
+
expect(q.toArray()).toEqual([7]);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
test("Symbol.iterator",()=>{
|
|
270
|
+
const q = new Deque();
|
|
271
|
+
|
|
272
|
+
q.addLast(1);
|
|
273
|
+
q.addLast(7);
|
|
274
|
+
|
|
275
|
+
expect(Array.from(q)).toEqual([1,7]);
|
|
276
|
+
});
|
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 3D ray
|
|
3
3
|
*/
|
|
4
|
-
export class Ray3 {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
get
|
|
8
|
-
|
|
9
|
-
get
|
|
10
|
-
get
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
export class Ray3 extends Float32Array {
|
|
5
|
+
constructor();
|
|
6
|
+
set tMax(arg: any);
|
|
7
|
+
get tMax(): any;
|
|
8
|
+
6: any;
|
|
9
|
+
get direction(): Float32Array;
|
|
10
|
+
get origin(): Float32Array;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param {number} distance
|
|
14
|
+
*/
|
|
15
|
+
shiftForward(distance: number): void;
|
|
13
16
|
/**
|
|
14
17
|
*
|
|
15
18
|
* @param {number[]|mat4|Float32Array} m4
|
|
16
19
|
*/
|
|
17
20
|
applyMatrix4(m4: number[] | mat4 | Float32Array): void;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @returns {Ray3}
|
|
24
|
+
*/
|
|
25
|
+
clone(): Ray3;
|
|
18
26
|
/**
|
|
19
27
|
*
|
|
20
28
|
* @param {Ray3} other
|
|
21
29
|
*/
|
|
22
30
|
copy(other: Ray3): void;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param {Ray3} other
|
|
34
|
+
* @returns {boolean}
|
|
35
|
+
*/
|
|
36
|
+
equals(other: Ray3): boolean;
|
|
23
37
|
}
|
|
24
|
-
import Vector3 from "../Vector3.js";
|
|
25
38
|
//# sourceMappingURL=Ray3.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ray3.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/3d/Ray3.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Ray3.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/3d/Ray3.js"],"names":[],"mappings":"AAKA;;GAEG;AACH;IACI,cAKC;IAMD,mBAEC;IAND,gBAEC;IAGG,OAAW;IAGf,8BAEC;IAED,2BAEC;IAED;;;OAGG;IACH,uBAFW,MAAM,QAMhB;IAED;;;OAGG;IACH,iBAFW,MAAM,EAAE,UAAM,YAAY,QAepC;IAED;;;OAGG;IACH,SAFa,IAAI,CAQhB;IAED;;;OAGG;IACH,YAFW,IAAI,QAId;IAED;;;;OAIG;IACH,cAHW,IAAI,GACF,OAAO,CAInB;CACJ"}
|
package/src/core/geom/3d/Ray3.js
CHANGED
|
@@ -1,34 +1,43 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { array_range_equal_strict } from "../../collection/array/array_range_equal_strict.js";
|
|
2
|
+
import { v3_matrix4_multiply } from "../vec3/v3_matrix4_multiply.js";
|
|
3
|
+
import { v3_matrix4_rotate } from "../vec3/v3_matrix4_rotate.js";
|
|
4
|
+
import { ray3_interval_array_apply_matrix4 } from "./ray/ray3_interval_array_apply_matrix4.js";
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* 3D ray
|
|
5
8
|
*/
|
|
6
|
-
export class Ray3 {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
export class Ray3 extends Float32Array {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(7);
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
// make ray unbounded
|
|
14
|
+
this.tMax = Infinity;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
get
|
|
15
|
-
return this
|
|
17
|
+
get tMax() {
|
|
18
|
+
return this[6];
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
set tMax(v) {
|
|
22
|
+
this[6] = v;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
get
|
|
23
|
-
return this.
|
|
25
|
+
get direction() {
|
|
26
|
+
return new Float32Array(this.buffer, this.byteOffset + 3, 3);
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
get
|
|
27
|
-
return this.
|
|
29
|
+
get origin() {
|
|
30
|
+
return new Float32Array(this.buffer, this.byteOffset, 3);
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param {number} distance
|
|
36
|
+
*/
|
|
37
|
+
shiftForward(distance) {
|
|
38
|
+
this[0] += this[3] * distance;
|
|
39
|
+
this[1] += this[4] * distance;
|
|
40
|
+
this[2] += this[5] * distance;
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
/**
|
|
@@ -36,8 +45,30 @@ export class Ray3 {
|
|
|
36
45
|
* @param {number[]|mat4|Float32Array} m4
|
|
37
46
|
*/
|
|
38
47
|
applyMatrix4(m4) {
|
|
39
|
-
|
|
40
|
-
this
|
|
48
|
+
|
|
49
|
+
if (this[6] !== Infinity) {
|
|
50
|
+
|
|
51
|
+
ray3_interval_array_apply_matrix4(this, 0, this, 0, m4);
|
|
52
|
+
|
|
53
|
+
} else {
|
|
54
|
+
|
|
55
|
+
// special case
|
|
56
|
+
v3_matrix4_multiply(this, 0, this, 0, m4);
|
|
57
|
+
v3_matrix4_rotate(this, 3, this, 3, m4);
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @returns {Ray3}
|
|
65
|
+
*/
|
|
66
|
+
clone() {
|
|
67
|
+
const r = new Ray3();
|
|
68
|
+
|
|
69
|
+
r.copy(this);
|
|
70
|
+
|
|
71
|
+
return r;
|
|
41
72
|
}
|
|
42
73
|
|
|
43
74
|
/**
|
|
@@ -45,7 +76,15 @@ export class Ray3 {
|
|
|
45
76
|
* @param {Ray3} other
|
|
46
77
|
*/
|
|
47
78
|
copy(other) {
|
|
48
|
-
this.
|
|
49
|
-
|
|
79
|
+
this.set(other);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @param {Ray3} other
|
|
85
|
+
* @returns {boolean}
|
|
86
|
+
*/
|
|
87
|
+
equals(other) {
|
|
88
|
+
return array_range_equal_strict(this, 0, other, 0, 7);
|
|
50
89
|
}
|
|
51
90
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
|
-
* @param {number[]|ArrayLike<number>|Float32Array} output
|
|
3
|
+
* @param {number[]|ArrayLike<number>|Float32Array} output 7 component vector, [origin_x, origin_y, origin_z, direction_x, direction_y, direction_z, tMax]
|
|
4
4
|
* @param {number} output_offset
|
|
5
|
-
* @param {number[]|ArrayLike<number>|Float32Array} input
|
|
5
|
+
* @param {number[]|ArrayLike<number>|Float32Array} input 7 component vector, [origin_x, origin_y, origin_z, direction_x, direction_y, direction_z, tMax]
|
|
6
6
|
* @param {number} input_offset
|
|
7
7
|
* @param {number[]|ArrayLike<number>|Float32Array} m4 4x4 matrix
|
|
8
8
|
* @returns {boolean} false if matrix transformation is impossible, such as when scale of the matrix is 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ray3_interval_array_apply_matrix4.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/ray/ray3_interval_array_apply_matrix4.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,0DAPW,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,iBACvC,MAAM,SACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,gBACvC,MAAM,MACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,GACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"ray3_interval_array_apply_matrix4.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/ray/ray3_interval_array_apply_matrix4.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,0DAPW,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,iBACvC,MAAM,SACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,gBACvC,MAAM,MACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,GACrC,OAAO,CAoEnB"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
|
-
* @param {number[]|ArrayLike<number>|Float32Array} output
|
|
3
|
+
* @param {number[]|ArrayLike<number>|Float32Array} output 7 component vector, [origin_x, origin_y, origin_z, direction_x, direction_y, direction_z, tMax]
|
|
4
4
|
* @param {number} output_offset
|
|
5
|
-
* @param {number[]|ArrayLike<number>|Float32Array} input
|
|
5
|
+
* @param {number[]|ArrayLike<number>|Float32Array} input 7 component vector, [origin_x, origin_y, origin_z, direction_x, direction_y, direction_z, tMax]
|
|
6
6
|
* @param {number} input_offset
|
|
7
7
|
* @param {number[]|ArrayLike<number>|Float32Array} m4 4x4 matrix
|
|
8
8
|
* @returns {boolean} false if matrix transformation is impossible, such as when scale of the matrix is 0
|
|
9
9
|
*/
|
|
10
|
-
export function ray3_interval_array_apply_matrix4(
|
|
10
|
+
export function ray3_interval_array_apply_matrix4(
|
|
11
|
+
output, output_offset,
|
|
12
|
+
input, input_offset,
|
|
13
|
+
m4
|
|
14
|
+
) {
|
|
11
15
|
const origin_x = input[input_offset + 0];
|
|
12
16
|
const origin_y = input[input_offset + 1];
|
|
13
17
|
const origin_z = input[input_offset + 2];
|
|
@@ -16,46 +20,57 @@ export function ray3_interval_array_apply_matrix4(output, output_offset, input,
|
|
|
16
20
|
const direction_y = input[input_offset + 4];
|
|
17
21
|
const direction_z = input[input_offset + 5];
|
|
18
22
|
|
|
23
|
+
const t_max = input[input_offset + 6];
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
const in_min_x = origin_x ;
|
|
27
|
+
const in_min_y = origin_y ;
|
|
28
|
+
const in_min_z = origin_z ;
|
|
29
|
+
|
|
30
|
+
const in_max_x = origin_x + direction_x * t_max;
|
|
31
|
+
const in_max_y = origin_y + direction_y * t_max;
|
|
32
|
+
const in_max_z = origin_z + direction_z * t_max;
|
|
33
|
+
|
|
19
34
|
// transform ray to local space (inlined for speed)
|
|
20
|
-
const
|
|
35
|
+
const w0 = m4[3] * in_min_x + m4[7] * in_min_y + m4[11] * in_min_z + m4[15];
|
|
21
36
|
|
|
22
|
-
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
37
|
+
const inv_w0 = 1 / w0;
|
|
25
38
|
|
|
26
|
-
const
|
|
39
|
+
const out_min_x = (m4[0] * in_min_x + m4[4] * in_min_y + m4[8] * in_min_z + m4[12]) * inv_w0;
|
|
40
|
+
const out_min_y = (m4[1] * in_min_x + m4[5] * in_min_y + m4[9] * in_min_z + m4[13]) * inv_w0;
|
|
41
|
+
const out_min_z = (m4[2] * in_min_x + m4[6] * in_min_y + m4[10] * in_min_z + m4[14]) * inv_w0;
|
|
27
42
|
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const out_origin_z = (m4[2] * origin_x + m4[6] * origin_y + m4[10] * origin_z + m4[14]) * inv_w;
|
|
43
|
+
// transform ray to local space (inlined for speed)
|
|
44
|
+
const w1 = m4[3] * in_max_x + m4[7] * in_max_y + m4[11] * in_max_z + m4[15];
|
|
31
45
|
|
|
32
|
-
const
|
|
33
|
-
const out_direction_y = m4[1] * direction_x + m4[5] * direction_y + m4[9] * direction_z;
|
|
34
|
-
const out_direction_z = m4[2] * direction_x + m4[6] * direction_y + m4[10] * direction_z;
|
|
46
|
+
const inv_w1 = 1 / w1;
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
const
|
|
48
|
+
const out_max_x = (m4[0] * in_max_x + m4[4] * in_max_y + m4[8] * in_max_z + m4[12]) * inv_w1;
|
|
49
|
+
const out_max_y = (m4[1] * in_max_x + m4[5] * in_max_y + m4[9] * in_max_z + m4[13]) * inv_w1;
|
|
50
|
+
const out_max_z = (m4[2] * in_max_x + m4[6] * in_max_y + m4[10] * in_max_z + m4[14]) * inv_w1;
|
|
38
51
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
52
|
+
const delta_x = out_max_x - out_min_x;
|
|
53
|
+
const delta_y = out_max_y - out_min_y;
|
|
54
|
+
const delta_z = out_max_z - out_min_z;
|
|
55
|
+
|
|
56
|
+
// normalize direction
|
|
57
|
+
const out_direction_magnitude = Math.hypot(delta_x, delta_y, delta_z);
|
|
42
58
|
|
|
43
59
|
const out_direction_magnitude_inverse = 1 / out_direction_magnitude;
|
|
44
60
|
|
|
45
|
-
const out_direction_normalized_x =
|
|
46
|
-
const out_direction_normalized_y =
|
|
47
|
-
const out_direction_normalized_z =
|
|
61
|
+
const out_direction_normalized_x = delta_x * out_direction_magnitude_inverse;
|
|
62
|
+
const out_direction_normalized_y = delta_y * out_direction_magnitude_inverse;
|
|
63
|
+
const out_direction_normalized_z = delta_z * out_direction_magnitude_inverse;
|
|
48
64
|
|
|
49
|
-
output[output_offset + 0] =
|
|
50
|
-
output[output_offset + 1] =
|
|
51
|
-
output[output_offset + 2] =
|
|
65
|
+
output[output_offset + 0] = out_min_x;
|
|
66
|
+
output[output_offset + 1] = out_min_y;
|
|
67
|
+
output[output_offset + 2] = out_min_z;
|
|
52
68
|
|
|
53
69
|
output[output_offset + 3] = out_direction_normalized_x;
|
|
54
70
|
output[output_offset + 4] = out_direction_normalized_y;
|
|
55
71
|
output[output_offset + 5] = out_direction_normalized_z;
|
|
56
72
|
|
|
57
|
-
|
|
58
|
-
throw new Error("Not Implemented")
|
|
73
|
+
output[output_offset + 6] = out_direction_magnitude;
|
|
59
74
|
|
|
60
75
|
return true;
|
|
61
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace_triangular_depth_map.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"trace_triangular_depth_map.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.js"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AACH,mDATW,WAAW,iBACX,MAAM,UACN,MAAM,EAAE,GAAC,YAAY,UACrB,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,gCA2GhB"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { v3_length } from "../../../vec3/v3_length.js";
|
|
2
2
|
import { ray3_array_compose } from "../../ray/ray3_array_compose.js";
|
|
3
|
+
import { Ray3 } from "../../Ray3.js";
|
|
3
4
|
|
|
4
5
|
const scratch = [];
|
|
5
|
-
const ray =
|
|
6
|
+
const ray = new Ray3();
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
*
|
|
@@ -92,7 +93,9 @@ export function trace_triangular_depth_map(
|
|
|
92
93
|
ray_direction_x, ray_direction_y, ray_direction_z
|
|
93
94
|
);
|
|
94
95
|
|
|
95
|
-
|
|
96
|
+
ray.tMax = distance_to_target;
|
|
97
|
+
|
|
98
|
+
const distance = scene.trace(scratch, ray);
|
|
96
99
|
|
|
97
100
|
let depth;
|
|
98
101
|
if (distance < 0) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Perform rotation on a direction vector using 3x3 portion of a 4x4 matrix
|
|
3
|
+
* @param {number[]|Float32Array} output
|
|
4
|
+
* @param {number} output_offset
|
|
5
|
+
* @param {number[]|Float32Array} input
|
|
6
|
+
* @param {number} input_offset
|
|
7
|
+
* @param {number[]|Float32Array} m4
|
|
8
|
+
*/
|
|
9
|
+
export function v3_matrix4_rotate(output: number[] | Float32Array, output_offset: number, input: number[] | Float32Array, input_offset: number, m4: number[] | Float32Array): void;
|
|
10
|
+
//# sourceMappingURL=v3_matrix4_rotate.d.ts.map
|