angular-three-soba 3.6.1 → 4.0.0-next.1
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/abstractions/lib/billboard.d.ts +6 -6
- package/abstractions/lib/catmull-rom-line.d.ts +173 -563
- package/abstractions/lib/cubic-bezier-line.d.ts +7 -7
- package/abstractions/lib/edges.d.ts +171 -747
- package/abstractions/lib/gradient-texture.d.ts +8 -8
- package/abstractions/lib/grid.d.ts +24 -292
- package/abstractions/lib/helper.d.ts +5 -5
- package/abstractions/lib/line.d.ts +11 -12
- package/abstractions/lib/prism-geometry.d.ts +12 -12
- package/abstractions/lib/quadratic-bezier-line.d.ts +7 -7
- package/abstractions/lib/rounded-box.d.ts +8 -8
- package/abstractions/lib/text-3d.d.ts +14 -293
- package/abstractions/lib/text.d.ts +12 -13
- package/cameras/lib/camera-content.d.ts +2 -2
- package/cameras/lib/cube-camera.d.ts +12 -12
- package/cameras/lib/orthographic-camera.d.ts +11 -11
- package/cameras/lib/perspective-camera.d.ts +10 -10
- package/controls/lib/camera-controls.d.ts +1 -6
- package/controls/lib/orbit-controls.d.ts +6 -10
- package/controls/lib/scroll-controls.d.ts +8 -14
- package/fesm2022/angular-three-soba-abstractions.mjs +75 -52
- package/fesm2022/angular-three-soba-abstractions.mjs.map +1 -1
- package/fesm2022/angular-three-soba-cameras.mjs +18 -20
- package/fesm2022/angular-three-soba-cameras.mjs.map +1 -1
- package/fesm2022/angular-three-soba-controls.mjs +65 -65
- package/fesm2022/angular-three-soba-controls.mjs.map +1 -1
- package/fesm2022/angular-three-soba-gizmos.mjs +185 -194
- package/fesm2022/angular-three-soba-gizmos.mjs.map +1 -1
- package/fesm2022/angular-three-soba-loaders.mjs +21 -16
- package/fesm2022/angular-three-soba-loaders.mjs.map +1 -1
- package/fesm2022/angular-three-soba-materials.mjs +90 -93
- package/fesm2022/angular-three-soba-materials.mjs.map +1 -1
- package/fesm2022/angular-three-soba-misc.mjs +282 -279
- package/fesm2022/angular-three-soba-misc.mjs.map +1 -1
- package/fesm2022/angular-three-soba-performances.mjs +51 -56
- package/fesm2022/angular-three-soba-performances.mjs.map +1 -1
- package/fesm2022/angular-three-soba-shaders.mjs +5 -6
- package/fesm2022/angular-three-soba-shaders.mjs.map +1 -1
- package/fesm2022/angular-three-soba-staging.mjs +253 -277
- package/fesm2022/angular-three-soba-staging.mjs.map +1 -1
- package/fesm2022/angular-three-soba-stats.mjs +3 -4
- package/fesm2022/angular-three-soba-stats.mjs.map +1 -1
- package/gizmos/lib/gizmo-helper/gizmo-helper.d.ts +12 -15
- package/gizmos/lib/gizmo-helper/gizmo-viewcube.d.ts +5 -6
- package/gizmos/lib/gizmo-helper/gizmo-viewport.d.ts +8 -9
- package/gizmos/lib/pivot-controls/axis-arrow.d.ts +11 -13
- package/gizmos/lib/pivot-controls/axis-rotator.d.ts +11 -12
- package/gizmos/lib/pivot-controls/pivot-controls.d.ts +28 -29
- package/gizmos/lib/pivot-controls/plane-slider.d.ts +12 -13
- package/gizmos/lib/pivot-controls/scaling-sphere.d.ts +12 -14
- package/gizmos/lib/transform-controls.d.ts +15 -20
- package/loaders/lib/loader.d.ts +10 -11
- package/loaders/lib/texture-loader.d.ts +3 -3
- package/materials/lib/custom-shader-material.d.ts +3 -3
- package/materials/lib/mesh-distort-material.d.ts +3 -3
- package/materials/lib/mesh-portal-material.d.ts +19 -118
- package/materials/lib/mesh-reflector-material.d.ts +4 -5
- package/materials/lib/mesh-refraction-material.d.ts +13 -14
- package/materials/lib/mesh-transmission-material.d.ts +14 -14
- package/materials/lib/mesh-wobble-material.d.ts +4 -4
- package/materials/lib/point-material.d.ts +3 -3
- package/misc/lib/animations.d.ts +12 -12
- package/misc/lib/computed-attribute.d.ts +5 -48
- package/misc/lib/decal.d.ts +9 -9
- package/misc/lib/deprecated.d.ts +2 -2
- package/misc/lib/depth-buffer.d.ts +2 -2
- package/misc/lib/fbo.d.ts +9 -9
- package/misc/lib/html/html-content.d.ts +5 -7
- package/misc/lib/html/html.d.ts +15 -14
- package/misc/lib/html/utils.d.ts +9 -9
- package/misc/lib/intersect.d.ts +2 -2
- package/misc/lib/preload.d.ts +3 -6
- package/misc/lib/sampler.d.ts +22 -21
- package/misc/lib/scale-factor.d.ts +2 -2
- package/package.json +141 -141
- package/performances/lib/detailed.d.ts +5 -5
- package/performances/lib/instances/instances.d.ts +8 -96
- package/performances/lib/instances/position-mesh.d.ts +8 -8
- package/performances/lib/points/points.d.ts +10 -188
- package/performances/lib/points/position-point.d.ts +8 -8
- package/performances/lib/segments/segment-object.d.ts +6 -6
- package/performances/lib/segments/segments.d.ts +34 -35
- package/shaders/lib/grid-material.d.ts +16 -16
- package/shaders/lib/mesh-refraction-material.d.ts +2 -2
- package/shaders/lib/point-material.d.ts +5 -5
- package/staging/lib/accumulative-shadows.d.ts +21 -25
- package/staging/lib/backdrop.d.ts +8 -8
- package/staging/lib/bb-anchor.d.ts +5 -5
- package/staging/lib/bounds.d.ts +13 -17
- package/staging/lib/camera-shake.d.ts +0 -2
- package/staging/lib/caustics.d.ts +11 -11
- package/staging/lib/center.d.ts +10 -350
- package/staging/lib/contact-shadows.d.ts +17 -16
- package/staging/lib/environment/environment.d.ts +13 -15
- package/staging/lib/environment/inject-environment.d.ts +3 -3
- package/staging/lib/float.d.ts +5 -5
- package/staging/lib/lightformer.d.ts +11 -290
- package/staging/lib/mask.d.ts +8 -10
- package/staging/lib/matcap-texture.d.ts +5 -5
- package/staging/lib/normal-texture.d.ts +5 -5
- package/staging/lib/randomized-lights.d.ts +13 -13
- package/staging/lib/render-texture.d.ts +21 -17
- package/staging/lib/sky.d.ts +13 -13
- package/staging/lib/spot-light.d.ts +39 -39
- package/staging/lib/stage.d.ts +108 -278
- package/vanilla-exports/index.d.ts +6 -7
- package/LICENSE +0 -21
- package/metadata.json +0 -1
- package/web-types.json +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { computed, isSignal, signal, effect, untracked, Directive, input, viewChild, Component, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, inject, DestroyRef, TemplateRef, ViewContainerRef, output, Renderer2, model
|
|
3
|
-
import { injectBeforeRender, resolveRef, injectStore,
|
|
2
|
+
import { computed, isSignal, signal, effect, untracked, Directive, input, viewChild, Component, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, inject, DestroyRef, TemplateRef, ViewContainerRef, output, ElementRef, Renderer2, model } from '@angular/core';
|
|
3
|
+
import { injectBeforeRender, resolveRef, injectStore, getInstanceState, NgtArgs, omit, pick, extend, is, applyProps, NgtHTML, addEffect, addAfterEffect, checkUpdate } from 'angular-three';
|
|
4
4
|
import { assertInjector } from 'ngxtension/assert-injector';
|
|
5
|
-
import
|
|
5
|
+
import * as THREE from 'three';
|
|
6
|
+
import { REVISION, Mesh, BoxGeometry, MeshNormalMaterial, AxesHelper, Group, PlaneGeometry, ShaderMaterial } from 'three';
|
|
6
7
|
import { mergeInputs } from 'ngxtension/inject-inputs';
|
|
7
8
|
import { DecalGeometry, MeshSurfaceSampler } from 'three-stdlib';
|
|
8
9
|
import { NgTemplateOutlet } from '@angular/common';
|
|
@@ -12,7 +13,7 @@ import { NgTemplateOutlet } from '@angular/common';
|
|
|
12
13
|
*/
|
|
13
14
|
function injectAnimations(animations, object, { injector } = {}) {
|
|
14
15
|
return assertInjector(injectAnimations, injector, () => {
|
|
15
|
-
const mixer = new AnimationMixer(null);
|
|
16
|
+
const mixer = new THREE.AnimationMixer(null);
|
|
16
17
|
injectBeforeRender(({ delta }) => {
|
|
17
18
|
if (!mixer.getRoot())
|
|
18
19
|
return;
|
|
@@ -77,13 +78,12 @@ function injectAnimations(animations, object, { injector } = {}) {
|
|
|
77
78
|
class NgtsBakeShadows {
|
|
78
79
|
constructor() {
|
|
79
80
|
const store = injectStore();
|
|
80
|
-
const gl = store.select('gl');
|
|
81
81
|
effect((onCleanup) => {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
const gl = store.gl();
|
|
83
|
+
gl.shadowMap.autoUpdate = false;
|
|
84
|
+
gl.shadowMap.needsUpdate = true;
|
|
85
85
|
onCleanup(() => {
|
|
86
|
-
|
|
86
|
+
gl.shadowMap.autoUpdate = gl.shadowMap.needsUpdate = true;
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
89
|
}
|
|
@@ -105,16 +105,16 @@ class NgtsComputedAttribute {
|
|
|
105
105
|
this.compute = input.required();
|
|
106
106
|
this.name = input.required();
|
|
107
107
|
this.options = input({});
|
|
108
|
-
this.bufferAttribute = new BufferAttribute(new Float32Array(0), 1);
|
|
108
|
+
this.bufferAttribute = new THREE.BufferAttribute(new Float32Array(0), 1);
|
|
109
109
|
this.attributeRef = viewChild('attribute');
|
|
110
110
|
effect(() => {
|
|
111
111
|
const bufferAttribute = this.attributeRef()?.nativeElement;
|
|
112
112
|
if (!bufferAttribute)
|
|
113
113
|
return;
|
|
114
|
-
const
|
|
115
|
-
if (!
|
|
114
|
+
const instanceState = getInstanceState(bufferAttribute);
|
|
115
|
+
if (!instanceState)
|
|
116
116
|
return;
|
|
117
|
-
const geometry = bufferAttribute.parent ??
|
|
117
|
+
const geometry = bufferAttribute.parent ?? instanceState.parent();
|
|
118
118
|
const attribute = this.compute()(geometry);
|
|
119
119
|
bufferAttribute.copy(attribute);
|
|
120
120
|
});
|
|
@@ -175,20 +175,20 @@ class NgtsDecal {
|
|
|
175
175
|
extend({ Mesh, BoxGeometry, MeshNormalMaterial, AxesHelper });
|
|
176
176
|
effect((onCleanup) => {
|
|
177
177
|
const thisMesh = this.meshRef().nativeElement;
|
|
178
|
-
const
|
|
179
|
-
if (!
|
|
178
|
+
const instanceState = getInstanceState(thisMesh);
|
|
179
|
+
if (!instanceState)
|
|
180
180
|
return;
|
|
181
|
-
const parent = resolveRef(this.mesh()) ||
|
|
182
|
-
if (parent && !parent
|
|
181
|
+
const parent = resolveRef(this.mesh()) || instanceState.parent();
|
|
182
|
+
if (parent && !is.three(parent, 'isMesh')) {
|
|
183
183
|
throw new Error('<ngts-decal> must have a Mesh as parent or specify its "mesh" input');
|
|
184
184
|
}
|
|
185
185
|
if (!parent)
|
|
186
186
|
return;
|
|
187
|
-
const
|
|
188
|
-
if (!
|
|
187
|
+
const parentInstanceState = getInstanceState(parent);
|
|
188
|
+
if (!parentInstanceState)
|
|
189
189
|
return;
|
|
190
190
|
// track parent's children
|
|
191
|
-
const parentNonObjects =
|
|
191
|
+
const parentNonObjects = parentInstanceState.nonObjects();
|
|
192
192
|
if (!parentNonObjects || !parentNonObjects.length) {
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
@@ -197,18 +197,18 @@ class NgtsDecal {
|
|
|
197
197
|
return;
|
|
198
198
|
}
|
|
199
199
|
const [position, rotation, scale] = [this.position(), this.rotation(), this.scale()];
|
|
200
|
-
const state = { position: new Vector3(), rotation: new Euler(), scale: new Vector3(1, 1, 1) };
|
|
200
|
+
const state = { position: new THREE.Vector3(), rotation: new THREE.Euler(), scale: new THREE.Vector3(1, 1, 1) };
|
|
201
201
|
applyProps(state, { position, scale });
|
|
202
202
|
// zero out the parents matrix world for this operation
|
|
203
203
|
const matrixWorld = parent.matrixWorld.clone();
|
|
204
204
|
parent.matrixWorld.identity();
|
|
205
205
|
if (!rotation || typeof rotation === 'number') {
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
const obj = new THREE.Object3D();
|
|
207
|
+
obj.position.copy(state.position);
|
|
208
|
+
obj.lookAt(parent.position);
|
|
209
209
|
if (typeof rotation === 'number')
|
|
210
|
-
|
|
211
|
-
applyProps(state, { rotation:
|
|
210
|
+
obj.rotateZ(rotation);
|
|
211
|
+
applyProps(state, { rotation: obj.rotation });
|
|
212
212
|
}
|
|
213
213
|
else {
|
|
214
214
|
applyProps(state, { rotation });
|
|
@@ -243,7 +243,7 @@ class NgtsDecal {
|
|
|
243
243
|
@if (debug()) {
|
|
244
244
|
<ngt-mesh #helper>
|
|
245
245
|
<ngt-box-geometry />
|
|
246
|
-
<ngt-mesh-normal-material
|
|
246
|
+
<ngt-mesh-normal-material wireframe />
|
|
247
247
|
<ngt-axes-helper />
|
|
248
248
|
</ngt-mesh>
|
|
249
249
|
}
|
|
@@ -269,7 +269,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImpor
|
|
|
269
269
|
@if (debug()) {
|
|
270
270
|
<ngt-mesh #helper>
|
|
271
271
|
<ngt-box-geometry />
|
|
272
|
-
<ngt-mesh-normal-material
|
|
272
|
+
<ngt-mesh-normal-material wireframe />
|
|
273
273
|
<ngt-axes-helper />
|
|
274
274
|
</ngt-mesh>
|
|
275
275
|
}
|
|
@@ -298,15 +298,13 @@ const sRGBEncoding = 3001;
|
|
|
298
298
|
function injectFBO(params = () => ({}), { injector } = {}) {
|
|
299
299
|
return assertInjector(injectFBO, injector, () => {
|
|
300
300
|
const store = injectStore();
|
|
301
|
-
const size = store.select('size');
|
|
302
|
-
const viewport = store.select('viewport');
|
|
303
301
|
const width = computed(() => {
|
|
304
302
|
const { width } = params();
|
|
305
|
-
return typeof width === 'number' ? width : size()
|
|
303
|
+
return typeof width === 'number' ? width : store.size.width() * store.viewport.dpr();
|
|
306
304
|
});
|
|
307
305
|
const height = computed(() => {
|
|
308
306
|
const { height } = params();
|
|
309
|
-
return typeof height === 'number' ? height : size()
|
|
307
|
+
return typeof height === 'number' ? height : store.size.height() * store.viewport.dpr();
|
|
310
308
|
});
|
|
311
309
|
const settings = computed(() => {
|
|
312
310
|
const { width, settings } = params();
|
|
@@ -322,14 +320,14 @@ function injectFBO(params = () => ({}), { injector } = {}) {
|
|
|
322
320
|
untracked(width),
|
|
323
321
|
untracked(height),
|
|
324
322
|
];
|
|
325
|
-
const target = new WebGLRenderTarget(_width, _height, {
|
|
326
|
-
minFilter: LinearFilter,
|
|
327
|
-
magFilter: LinearFilter,
|
|
328
|
-
type: HalfFloatType,
|
|
323
|
+
const target = new THREE.WebGLRenderTarget(_width, _height, {
|
|
324
|
+
minFilter: THREE.LinearFilter,
|
|
325
|
+
magFilter: THREE.LinearFilter,
|
|
326
|
+
type: THREE.HalfFloatType,
|
|
329
327
|
...targetSettings,
|
|
330
328
|
});
|
|
331
329
|
if (depth) {
|
|
332
|
-
target.depthTexture = new DepthTexture(_width, _height, FloatType);
|
|
330
|
+
target.depthTexture = new THREE.DepthTexture(_width, _height, THREE.FloatType);
|
|
333
331
|
}
|
|
334
332
|
target.samples = samples;
|
|
335
333
|
return target;
|
|
@@ -378,15 +376,15 @@ function injectDepthBuffer(params = () => ({}), { injector } = {}) {
|
|
|
378
376
|
const size = computed(() => params().size || 256);
|
|
379
377
|
const frames = computed(() => params().frames || Infinity);
|
|
380
378
|
const store = injectStore();
|
|
381
|
-
const width = store.select('size', 'width');
|
|
382
|
-
const height = store.select('size', 'height');
|
|
383
|
-
const dpr = store.select('viewport', 'dpr');
|
|
384
|
-
const w = computed(() => size() || width() * dpr());
|
|
385
|
-
const h = computed(() => size() || height() * dpr());
|
|
379
|
+
// const width = store.select('size', 'width');
|
|
380
|
+
// const height = store.select('size', 'height');
|
|
381
|
+
// const dpr = store.select('viewport', 'dpr');
|
|
382
|
+
const w = computed(() => size() || store.size.width() * store.viewport.dpr());
|
|
383
|
+
const h = computed(() => size() || store.size.height() * store.viewport.dpr());
|
|
386
384
|
const depthConfig = computed(() => {
|
|
387
|
-
const depthTexture = new DepthTexture(w(), h());
|
|
388
|
-
depthTexture.format = DepthFormat;
|
|
389
|
-
depthTexture.type = UnsignedShortType;
|
|
385
|
+
const depthTexture = new THREE.DepthTexture(w(), h());
|
|
386
|
+
depthTexture.format = THREE.DepthFormat;
|
|
387
|
+
depthTexture.type = THREE.UnsignedShortType;
|
|
390
388
|
return { depthTexture };
|
|
391
389
|
});
|
|
392
390
|
const depthFBO = injectFBO(() => ({ width: w(), height: h(), settings: depthConfig() }));
|
|
@@ -403,133 +401,10 @@ function injectDepthBuffer(params = () => ({}), { injector } = {}) {
|
|
|
403
401
|
});
|
|
404
402
|
}
|
|
405
403
|
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
receiveShadow: false,
|
|
411
|
-
};
|
|
412
|
-
class NgtsHTML {
|
|
413
|
-
constructor() {
|
|
414
|
-
this.options = input(defaultHtmlOptions, { transform: mergeInputs(defaultHtmlOptions) });
|
|
415
|
-
this.parameters = omit(this.options, ['occlude', 'castShadow', 'receiveShadow', 'transform']);
|
|
416
|
-
this.groupRef = viewChild.required('group');
|
|
417
|
-
this.occlusionMeshRef = viewChild('occlusionMesh');
|
|
418
|
-
this.occlusionGeometryRef = viewChild('occlusionGeometry');
|
|
419
|
-
this.occlude = pick(this.options, 'occlude');
|
|
420
|
-
this.transform = pick(this.options, 'transform');
|
|
421
|
-
this.castShadow = pick(this.options, 'castShadow');
|
|
422
|
-
this.receiveShadow = pick(this.options, 'receiveShadow');
|
|
423
|
-
this.scale = pick(this.options, 'scale');
|
|
424
|
-
this.isRaycastOcclusion = computed(() => {
|
|
425
|
-
const occlude = this.occlude();
|
|
426
|
-
return (occlude && occlude !== 'blending') || (Array.isArray(occlude) && occlude.length && is.ref(occlude[0]));
|
|
427
|
-
});
|
|
428
|
-
this.shaders = computed(() => {
|
|
429
|
-
const transform = this.transform();
|
|
430
|
-
const vertexShader = !transform
|
|
431
|
-
? /* language=glsl glsl */ `
|
|
432
|
-
/*
|
|
433
|
-
This shader is from the THREE's SpriteMaterial.
|
|
434
|
-
We need to turn the backing plane into a Sprite
|
|
435
|
-
(make it always face the camera) if "transfrom"
|
|
436
|
-
is false.
|
|
437
|
-
*/
|
|
438
|
-
#include <common>
|
|
439
|
-
|
|
440
|
-
void main() {
|
|
441
|
-
vec2 center = vec2(0., 1.);
|
|
442
|
-
float rotation = 0.0;
|
|
443
|
-
|
|
444
|
-
// This is somewhat arbitrary, but it seems to work well
|
|
445
|
-
// Need to figure out how to derive this dynamically if it even matters
|
|
446
|
-
float size = 0.03;
|
|
447
|
-
|
|
448
|
-
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
449
|
-
vec2 scale;
|
|
450
|
-
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
|
|
451
|
-
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
|
|
452
|
-
|
|
453
|
-
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
454
|
-
if ( isPerspective ) scale *= - mvPosition.z;
|
|
455
|
-
|
|
456
|
-
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size;
|
|
457
|
-
vec2 rotatedPosition;
|
|
458
|
-
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
|
459
|
-
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
|
460
|
-
mvPosition.xy += rotatedPosition;
|
|
461
|
-
|
|
462
|
-
gl_Position = projectionMatrix * mvPosition;
|
|
463
|
-
}
|
|
464
|
-
`
|
|
465
|
-
: undefined;
|
|
466
|
-
const fragmentShader = /* language=glsl glsl */ `
|
|
467
|
-
void main() {
|
|
468
|
-
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
469
|
-
}
|
|
470
|
-
`;
|
|
471
|
-
return { vertexShader, fragmentShader };
|
|
472
|
-
});
|
|
473
|
-
this.vertexShader = pick(this.shaders, 'vertexShader');
|
|
474
|
-
this.fragmentShader = pick(this.shaders, 'fragmentShader');
|
|
475
|
-
this.DoubleSide = DoubleSide;
|
|
476
|
-
extend({ Group, Mesh, PlaneGeometry, ShaderMaterial });
|
|
477
|
-
}
|
|
478
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtsHTML, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
479
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.6", type: NgtsHTML, isStandalone: true, selector: "ngts-html", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "groupRef", first: true, predicate: ["group"], descendants: true, isSignal: true }, { propertyName: "occlusionMeshRef", first: true, predicate: ["occlusionMesh"], descendants: true, isSignal: true }, { propertyName: "occlusionGeometryRef", first: true, predicate: ["occlusionGeometry"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
480
|
-
<ngt-group #group [parameters]="parameters()">
|
|
481
|
-
@if (occlude() && !isRaycastOcclusion()) {
|
|
482
|
-
<ngt-mesh #occlusionMesh [castShadow]="castShadow()" [receiveShadow]="receiveShadow()">
|
|
483
|
-
<ng-content select="[data-occlusion-geometry]">
|
|
484
|
-
<ngt-plane-geometry #occlusionGeometry />
|
|
485
|
-
</ng-content>
|
|
486
|
-
<ng-content select="[data-occlusion-material]">
|
|
487
|
-
<ngt-shader-material
|
|
488
|
-
[side]="DoubleSide"
|
|
489
|
-
[vertexShader]="vertexShader()"
|
|
490
|
-
[fragmentShader]="fragmentShader()"
|
|
491
|
-
/>
|
|
492
|
-
</ng-content>
|
|
493
|
-
</ngt-mesh>
|
|
494
|
-
}
|
|
495
|
-
</ngt-group>
|
|
496
|
-
|
|
497
|
-
<ng-content />
|
|
498
|
-
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
499
|
-
}
|
|
500
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtsHTML, decorators: [{
|
|
501
|
-
type: Component,
|
|
502
|
-
args: [{
|
|
503
|
-
selector: 'ngts-html',
|
|
504
|
-
template: `
|
|
505
|
-
<ngt-group #group [parameters]="parameters()">
|
|
506
|
-
@if (occlude() && !isRaycastOcclusion()) {
|
|
507
|
-
<ngt-mesh #occlusionMesh [castShadow]="castShadow()" [receiveShadow]="receiveShadow()">
|
|
508
|
-
<ng-content select="[data-occlusion-geometry]">
|
|
509
|
-
<ngt-plane-geometry #occlusionGeometry />
|
|
510
|
-
</ng-content>
|
|
511
|
-
<ng-content select="[data-occlusion-material]">
|
|
512
|
-
<ngt-shader-material
|
|
513
|
-
[side]="DoubleSide"
|
|
514
|
-
[vertexShader]="vertexShader()"
|
|
515
|
-
[fragmentShader]="fragmentShader()"
|
|
516
|
-
/>
|
|
517
|
-
</ng-content>
|
|
518
|
-
</ngt-mesh>
|
|
519
|
-
}
|
|
520
|
-
</ngt-group>
|
|
521
|
-
|
|
522
|
-
<ng-content />
|
|
523
|
-
`,
|
|
524
|
-
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
525
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
526
|
-
}]
|
|
527
|
-
}], ctorParameters: () => [] });
|
|
528
|
-
|
|
529
|
-
const v1 = new Vector3();
|
|
530
|
-
const v2 = new Vector3();
|
|
531
|
-
const v3 = new Vector3();
|
|
532
|
-
const v4 = new Vector2();
|
|
404
|
+
const v1 = new THREE.Vector3();
|
|
405
|
+
const v2 = new THREE.Vector3();
|
|
406
|
+
const v3 = new THREE.Vector3();
|
|
407
|
+
const v4 = new THREE.Vector2();
|
|
533
408
|
function defaultCalculatePosition(el, camera, size) {
|
|
534
409
|
const objectPos = v1.setFromMatrixPosition(el.matrixWorld);
|
|
535
410
|
objectPos.project(camera);
|
|
@@ -559,9 +434,9 @@ function isObjectVisible(el, camera, raycaster, occlude) {
|
|
|
559
434
|
return true;
|
|
560
435
|
}
|
|
561
436
|
function objectScale(el, camera) {
|
|
562
|
-
if (camera
|
|
437
|
+
if (is.three(camera, 'isOrthographicCamera'))
|
|
563
438
|
return camera.zoom;
|
|
564
|
-
if (camera
|
|
439
|
+
if (is.three(camera, 'isPerspectiveCamera')) {
|
|
565
440
|
const objectPos = v1.setFromMatrixPosition(el.matrixWorld);
|
|
566
441
|
const cameraPos = v2.setFromMatrixPosition(camera.matrixWorld);
|
|
567
442
|
const vFOV = (camera.fov * Math.PI) / 180;
|
|
@@ -572,7 +447,8 @@ function objectScale(el, camera) {
|
|
|
572
447
|
return 1;
|
|
573
448
|
}
|
|
574
449
|
function objectZIndex(el, camera, zIndexRange) {
|
|
575
|
-
if (camera
|
|
450
|
+
if (is.three(camera, 'isPerspectiveCamera') ||
|
|
451
|
+
is.three(camera, 'isOrthographicCamera')) {
|
|
576
452
|
const objectPos = v1.setFromMatrixPosition(el.matrixWorld);
|
|
577
453
|
const cameraPos = v2.setFromMatrixPosition(camera.matrixWorld);
|
|
578
454
|
const dist = objectPos.distanceTo(cameraPos);
|
|
@@ -616,18 +492,16 @@ class NgtsHTMLContent extends NgtHTML {
|
|
|
616
492
|
super();
|
|
617
493
|
this.options = input(defaultHtmlContentOptions, {
|
|
618
494
|
transform: mergeInputs(defaultHtmlContentOptions),
|
|
619
|
-
alias: '
|
|
495
|
+
alias: 'htmlContent',
|
|
620
496
|
});
|
|
621
497
|
this.occluded = output();
|
|
622
|
-
this.html = inject(NgtsHTML);
|
|
623
498
|
this.transformOuterRef = viewChild('transformOuter');
|
|
624
499
|
this.transformInnerRef = viewChild('transformInner');
|
|
625
500
|
this.containerRef = viewChild('container');
|
|
626
|
-
this.
|
|
627
|
-
this.
|
|
628
|
-
this.
|
|
629
|
-
this.
|
|
630
|
-
this.size = this.store.select('size');
|
|
501
|
+
this.html = inject(NgtsHTML);
|
|
502
|
+
this.host = inject(ElementRef);
|
|
503
|
+
this.store = injectStore();
|
|
504
|
+
this.size = this.store.size;
|
|
631
505
|
this.parent = pick(this.options, 'parent');
|
|
632
506
|
this.zIndexRange = pick(this.options, 'zIndexRange');
|
|
633
507
|
this.calculatePosition = pick(this.options, 'calculatePosition');
|
|
@@ -641,14 +515,14 @@ class NgtsHTMLContent extends NgtHTML {
|
|
|
641
515
|
const parent = resolveRef(this.parent());
|
|
642
516
|
if (parent)
|
|
643
517
|
return parent;
|
|
644
|
-
return (this.events()
|
|
518
|
+
return (this.store.events.connected?.() || this.store.gl.domElement.parentNode());
|
|
645
519
|
});
|
|
646
520
|
const renderer = inject(Renderer2);
|
|
647
521
|
let isMeshSizeSet = false;
|
|
648
522
|
effect(() => {
|
|
649
523
|
const [occlude, canvasEl, zIndexRange] = [
|
|
650
524
|
this.html.occlude(),
|
|
651
|
-
|
|
525
|
+
this.store.snapshot.gl.domElement,
|
|
652
526
|
untracked(this.zIndexRange),
|
|
653
527
|
];
|
|
654
528
|
if (occlude && occlude === 'blending') {
|
|
@@ -668,11 +542,11 @@ class NgtsHTMLContent extends NgtHTML {
|
|
|
668
542
|
this.target(),
|
|
669
543
|
this.host.nativeElement,
|
|
670
544
|
untracked(this.prepend),
|
|
671
|
-
|
|
545
|
+
this.store.snapshot.scene,
|
|
672
546
|
untracked(this.calculatePosition),
|
|
673
547
|
untracked(this.html.groupRef).nativeElement,
|
|
674
|
-
|
|
675
|
-
|
|
548
|
+
this.store.snapshot.size,
|
|
549
|
+
this.store.snapshot.camera,
|
|
676
550
|
];
|
|
677
551
|
scene.updateMatrixWorld();
|
|
678
552
|
renderer.setStyle(hostEl, 'position', 'absolute');
|
|
@@ -800,7 +674,7 @@ class NgtsHTMLContent extends NgtHTML {
|
|
|
800
674
|
if (!Array.isArray(scale)) {
|
|
801
675
|
occlusionMesh.scale.setScalar(1 / scale);
|
|
802
676
|
}
|
|
803
|
-
else if (scale
|
|
677
|
+
else if (is.three(scale, 'isVector3')) {
|
|
804
678
|
occlusionMesh.scale.copy(scale.clone().divideScalar(1));
|
|
805
679
|
}
|
|
806
680
|
else {
|
|
@@ -833,7 +707,7 @@ class NgtsHTMLContent extends NgtHTML {
|
|
|
833
707
|
});
|
|
834
708
|
}
|
|
835
709
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtsHTMLContent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
836
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.6", type: NgtsHTMLContent, isStandalone: true, selector: "[
|
|
710
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.6", type: NgtsHTMLContent, isStandalone: true, selector: "div[htmlContent]", inputs: { options: { classPropertyName: "options", publicName: "htmlContent", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { occluded: "occluded" }, host: { attributes: { "data-ngts-html-content": "" } }, viewQueries: [{ propertyName: "transformOuterRef", first: true, predicate: ["transformOuter"], descendants: true, isSignal: true }, { propertyName: "transformInnerRef", first: true, predicate: ["transformInner"], descendants: true, isSignal: true }, { propertyName: "containerRef", first: true, predicate: ["container"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: `
|
|
837
711
|
@if (html.transform()) {
|
|
838
712
|
<div
|
|
839
713
|
#transformOuter
|
|
@@ -852,10 +726,10 @@ class NgtsHTMLContent extends NgtHTML {
|
|
|
852
726
|
#container
|
|
853
727
|
style="position:absolute"
|
|
854
728
|
[style.transform]="center() ? 'translate3d(-50%,-50%,0)' : 'none'"
|
|
855
|
-
[style.top]="fullscreen() ? -size()
|
|
856
|
-
[style.left]="fullscreen() ? -size()
|
|
857
|
-
[style.width]="fullscreen() ? size()
|
|
858
|
-
[style.height]="fullscreen() ? size()
|
|
729
|
+
[style.top]="fullscreen() ? -size.height() / 2 + 'px' : 'unset'"
|
|
730
|
+
[style.left]="fullscreen() ? -size.width() / 2 + 'px' : 'unset'"
|
|
731
|
+
[style.width]="fullscreen() ? size.width() : 'unset'"
|
|
732
|
+
[style.height]="fullscreen() ? size.height() : 'unset'"
|
|
859
733
|
[class]="containerClass()"
|
|
860
734
|
[style]="containerStyle()"
|
|
861
735
|
>
|
|
@@ -871,7 +745,7 @@ class NgtsHTMLContent extends NgtHTML {
|
|
|
871
745
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtsHTMLContent, decorators: [{
|
|
872
746
|
type: Component,
|
|
873
747
|
args: [{
|
|
874
|
-
selector: '[
|
|
748
|
+
selector: 'div[htmlContent]',
|
|
875
749
|
template: `
|
|
876
750
|
@if (html.transform()) {
|
|
877
751
|
<div
|
|
@@ -891,10 +765,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImpor
|
|
|
891
765
|
#container
|
|
892
766
|
style="position:absolute"
|
|
893
767
|
[style.transform]="center() ? 'translate3d(-50%,-50%,0)' : 'none'"
|
|
894
|
-
[style.top]="fullscreen() ? -size()
|
|
895
|
-
[style.left]="fullscreen() ? -size()
|
|
896
|
-
[style.width]="fullscreen() ? size()
|
|
897
|
-
[style.height]="fullscreen() ? size()
|
|
768
|
+
[style.top]="fullscreen() ? -size.height() / 2 + 'px' : 'unset'"
|
|
769
|
+
[style.left]="fullscreen() ? -size.width() / 2 + 'px' : 'unset'"
|
|
770
|
+
[style.width]="fullscreen() ? size.width() : 'unset'"
|
|
771
|
+
[style.height]="fullscreen() ? size.height() : 'unset'"
|
|
898
772
|
[class]="containerClass()"
|
|
899
773
|
[style]="containerStyle()"
|
|
900
774
|
>
|
|
@@ -912,6 +786,129 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImpor
|
|
|
912
786
|
}]
|
|
913
787
|
}], ctorParameters: () => [] });
|
|
914
788
|
|
|
789
|
+
const defaultHtmlOptions = {
|
|
790
|
+
occlude: false,
|
|
791
|
+
transform: false,
|
|
792
|
+
castShadow: false,
|
|
793
|
+
receiveShadow: false,
|
|
794
|
+
};
|
|
795
|
+
class NgtsHTML {
|
|
796
|
+
constructor() {
|
|
797
|
+
this.options = input(defaultHtmlOptions, { transform: mergeInputs(defaultHtmlOptions) });
|
|
798
|
+
this.parameters = omit(this.options, ['occlude', 'castShadow', 'receiveShadow', 'transform']);
|
|
799
|
+
this.groupRef = viewChild.required('group');
|
|
800
|
+
this.occlusionMeshRef = viewChild('occlusionMesh');
|
|
801
|
+
this.occlusionGeometryRef = viewChild('occlusionGeometry');
|
|
802
|
+
this.castShadow = pick(this.options, 'castShadow');
|
|
803
|
+
this.receiveShadow = pick(this.options, 'receiveShadow');
|
|
804
|
+
this.occlude = pick(this.options, 'occlude');
|
|
805
|
+
this.transform = pick(this.options, 'transform');
|
|
806
|
+
this.isRaycastOcclusion = computed(() => {
|
|
807
|
+
const occlude = this.occlude();
|
|
808
|
+
return (occlude && occlude !== 'blending') || (Array.isArray(occlude) && occlude.length && is.ref(occlude[0]));
|
|
809
|
+
});
|
|
810
|
+
this.shaders = computed(() => {
|
|
811
|
+
const transform = this.transform();
|
|
812
|
+
const vertexShader = !transform
|
|
813
|
+
? /* language=glsl glsl */ `
|
|
814
|
+
/*
|
|
815
|
+
This shader is from the THREE's SpriteMaterial.
|
|
816
|
+
We need to turn the backing plane into a Sprite
|
|
817
|
+
(make it always face the camera) if "transfrom"
|
|
818
|
+
is false.
|
|
819
|
+
*/
|
|
820
|
+
#include <common>
|
|
821
|
+
|
|
822
|
+
void main() {
|
|
823
|
+
vec2 center = vec2(0., 1.);
|
|
824
|
+
float rotation = 0.0;
|
|
825
|
+
|
|
826
|
+
// This is somewhat arbitrary, but it seems to work well
|
|
827
|
+
// Need to figure out how to derive this dynamically if it even matters
|
|
828
|
+
float size = 0.03;
|
|
829
|
+
|
|
830
|
+
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
831
|
+
vec2 scale;
|
|
832
|
+
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
|
|
833
|
+
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
|
|
834
|
+
|
|
835
|
+
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
836
|
+
if ( isPerspective ) scale *= - mvPosition.z;
|
|
837
|
+
|
|
838
|
+
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size;
|
|
839
|
+
vec2 rotatedPosition;
|
|
840
|
+
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
|
841
|
+
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
|
842
|
+
mvPosition.xy += rotatedPosition;
|
|
843
|
+
|
|
844
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
845
|
+
}
|
|
846
|
+
`
|
|
847
|
+
: undefined;
|
|
848
|
+
const fragmentShader = /* language=glsl glsl */ `
|
|
849
|
+
void main() {
|
|
850
|
+
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
851
|
+
}
|
|
852
|
+
`;
|
|
853
|
+
return { vertexShader, fragmentShader };
|
|
854
|
+
});
|
|
855
|
+
this.vertexShader = pick(this.shaders, 'vertexShader');
|
|
856
|
+
this.fragmentShader = pick(this.shaders, 'fragmentShader');
|
|
857
|
+
this.DoubleSide = THREE.DoubleSide;
|
|
858
|
+
extend({ Group, Mesh, PlaneGeometry, ShaderMaterial });
|
|
859
|
+
}
|
|
860
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtsHTML, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
861
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.6", type: NgtsHTML, isStandalone: true, selector: "ngts-html", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "groupRef", first: true, predicate: ["group"], descendants: true, isSignal: true }, { propertyName: "occlusionMeshRef", first: true, predicate: ["occlusionMesh"], descendants: true, isSignal: true }, { propertyName: "occlusionGeometryRef", first: true, predicate: ["occlusionGeometry"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
862
|
+
<ngt-group #group [parameters]="parameters()">
|
|
863
|
+
@if (occlude() && !isRaycastOcclusion()) {
|
|
864
|
+
<ngt-mesh #occlusionMesh [castShadow]="castShadow()" [receiveShadow]="receiveShadow()">
|
|
865
|
+
<ng-content select="[data-occlusion-geometry]">
|
|
866
|
+
<ngt-plane-geometry #occlusionGeometry />
|
|
867
|
+
</ng-content>
|
|
868
|
+
<ng-content select="[data-occlusion-material]">
|
|
869
|
+
<ngt-shader-material
|
|
870
|
+
[side]="DoubleSide"
|
|
871
|
+
[vertexShader]="vertexShader()"
|
|
872
|
+
[fragmentShader]="fragmentShader()"
|
|
873
|
+
/>
|
|
874
|
+
</ng-content>
|
|
875
|
+
</ngt-mesh>
|
|
876
|
+
}
|
|
877
|
+
</ngt-group>
|
|
878
|
+
|
|
879
|
+
<ng-content />
|
|
880
|
+
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
881
|
+
}
|
|
882
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtsHTML, decorators: [{
|
|
883
|
+
type: Component,
|
|
884
|
+
args: [{
|
|
885
|
+
selector: 'ngts-html',
|
|
886
|
+
template: `
|
|
887
|
+
<ngt-group #group [parameters]="parameters()">
|
|
888
|
+
@if (occlude() && !isRaycastOcclusion()) {
|
|
889
|
+
<ngt-mesh #occlusionMesh [castShadow]="castShadow()" [receiveShadow]="receiveShadow()">
|
|
890
|
+
<ng-content select="[data-occlusion-geometry]">
|
|
891
|
+
<ngt-plane-geometry #occlusionGeometry />
|
|
892
|
+
</ng-content>
|
|
893
|
+
<ng-content select="[data-occlusion-material]">
|
|
894
|
+
<ngt-shader-material
|
|
895
|
+
[side]="DoubleSide"
|
|
896
|
+
[vertexShader]="vertexShader()"
|
|
897
|
+
[fragmentShader]="fragmentShader()"
|
|
898
|
+
/>
|
|
899
|
+
</ng-content>
|
|
900
|
+
</ngt-mesh>
|
|
901
|
+
}
|
|
902
|
+
</ngt-group>
|
|
903
|
+
|
|
904
|
+
<ng-content />
|
|
905
|
+
`,
|
|
906
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
907
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
908
|
+
}]
|
|
909
|
+
}], ctorParameters: () => [] });
|
|
910
|
+
const NgtsHTMLDeclarations = [NgtsHTML, NgtsHTMLContent];
|
|
911
|
+
|
|
915
912
|
function injectIntersect(object, { injector, source = signal(false) } = {}) {
|
|
916
913
|
return assertInjector(injectIntersect, injector, () => {
|
|
917
914
|
let check = false;
|
|
@@ -963,24 +960,21 @@ class NgtsPreload {
|
|
|
963
960
|
this.scene = model();
|
|
964
961
|
this.camera = model();
|
|
965
962
|
this.store = injectStore();
|
|
966
|
-
this.gl = this.store.select('gl');
|
|
967
|
-
this.defaultScene = this.store.select('scene');
|
|
968
|
-
this.defaultCamera = this.store.select('camera');
|
|
969
963
|
this.trueScene = computed(() => {
|
|
970
964
|
const scene = this.scene();
|
|
971
965
|
if (scene)
|
|
972
966
|
return resolveRef(scene);
|
|
973
|
-
return this.
|
|
967
|
+
return this.store.scene();
|
|
974
968
|
});
|
|
975
969
|
this.trueCamera = computed(() => {
|
|
976
970
|
const camera = this.camera();
|
|
977
971
|
if (camera)
|
|
978
972
|
return resolveRef(camera);
|
|
979
|
-
return this.
|
|
973
|
+
return this.store.camera();
|
|
980
974
|
});
|
|
981
975
|
effect(() => {
|
|
982
976
|
const invisible = [];
|
|
983
|
-
const [all, scene, camera, gl] = [this.all(), this.trueScene(), this.trueCamera(), this.gl()];
|
|
977
|
+
const [all, scene, camera, gl] = [this.all(), this.trueScene(), this.trueCamera(), this.store.gl()];
|
|
984
978
|
if (!scene || !camera)
|
|
985
979
|
return;
|
|
986
980
|
if (all) {
|
|
@@ -995,8 +989,8 @@ class NgtsPreload {
|
|
|
995
989
|
// Now compile the scene
|
|
996
990
|
gl.compile(scene, camera);
|
|
997
991
|
// And for good measure, hit it with a cube camera
|
|
998
|
-
const cubeRenderTarget = new WebGLCubeRenderTarget(128);
|
|
999
|
-
const cubeCamera = new CubeCamera(0.01, 100000, cubeRenderTarget);
|
|
992
|
+
const cubeRenderTarget = new THREE.WebGLCubeRenderTarget(128);
|
|
993
|
+
const cubeCamera = new THREE.CubeCamera(0.01, 100000, cubeRenderTarget);
|
|
1000
994
|
cubeCamera.update(gl, scene);
|
|
1001
995
|
cubeRenderTarget.dispose();
|
|
1002
996
|
// Flips these objects back
|
|
@@ -1011,59 +1005,57 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImpor
|
|
|
1011
1005
|
args: [{ selector: 'ngts-preload' }]
|
|
1012
1006
|
}], ctorParameters: () => [] });
|
|
1013
1007
|
|
|
1014
|
-
function
|
|
1015
|
-
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1008
|
+
function surfaceSampler(mesh, { count, transform, weight, instancedMesh, } = {}) {
|
|
1009
|
+
const initialBufferAttribute = (() => {
|
|
1010
|
+
const arr = Array.from({ length: count?.() ?? 16 }, () => [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]).flat();
|
|
1011
|
+
return new THREE.InstancedBufferAttribute(Float32Array.from(arr), 16);
|
|
1012
|
+
})();
|
|
1013
|
+
return computed(() => {
|
|
1014
|
+
const currentMesh = resolveRef(mesh());
|
|
1015
|
+
if (!currentMesh)
|
|
1016
|
+
return initialBufferAttribute;
|
|
1017
|
+
const instanceState = getInstanceState(currentMesh);
|
|
1018
|
+
if (!instanceState)
|
|
1019
|
+
return initialBufferAttribute;
|
|
1020
|
+
const nonObjects = instanceState.nonObjects();
|
|
1021
|
+
if (!nonObjects ||
|
|
1022
|
+
!nonObjects.length ||
|
|
1023
|
+
nonObjects.every((nonObject) => !is.three(nonObject, 'isBufferGeometry'))) {
|
|
1024
|
+
return initialBufferAttribute;
|
|
1025
|
+
}
|
|
1026
|
+
const sampler = new MeshSurfaceSampler(currentMesh);
|
|
1027
|
+
const _count = count?.() ?? 16;
|
|
1028
|
+
const _transform = transform?.();
|
|
1029
|
+
const _weight = weight?.();
|
|
1030
|
+
if (_weight) {
|
|
1031
|
+
sampler.setWeightAttribute(_weight);
|
|
1032
|
+
}
|
|
1033
|
+
sampler.build();
|
|
1034
|
+
const position = new THREE.Vector3();
|
|
1035
|
+
const normal = new THREE.Vector3();
|
|
1036
|
+
const color = new THREE.Color();
|
|
1037
|
+
const dummy = new THREE.Object3D();
|
|
1038
|
+
const instance = resolveRef(instancedMesh?.());
|
|
1039
|
+
currentMesh.updateMatrixWorld(true);
|
|
1040
|
+
for (let i = 0; i < _count; i++) {
|
|
1041
|
+
sampler.sample(position, normal, color);
|
|
1042
|
+
if (typeof _transform === 'function') {
|
|
1043
|
+
_transform({ dummy, sampledMesh: currentMesh, position, normal, color }, i);
|
|
1039
1044
|
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
const normal = new Vector3();
|
|
1043
|
-
const color = new Color();
|
|
1044
|
-
const dummy = new Object3D();
|
|
1045
|
-
const instance = resolveRef(instanceMesh);
|
|
1046
|
-
currentMesh.updateMatrixWorld(true);
|
|
1047
|
-
for (let i = 0; i < count; i++) {
|
|
1048
|
-
sampler.sample(position, normal, color);
|
|
1049
|
-
if (typeof transform === 'function') {
|
|
1050
|
-
transform({ dummy, sampledMesh: currentMesh, position, normal, color }, i);
|
|
1051
|
-
}
|
|
1052
|
-
else {
|
|
1053
|
-
dummy.position.copy(position);
|
|
1054
|
-
}
|
|
1055
|
-
dummy.updateMatrix();
|
|
1056
|
-
if (instance) {
|
|
1057
|
-
instance.setMatrixAt(i, dummy.matrix);
|
|
1058
|
-
}
|
|
1059
|
-
dummy.matrix.toArray(initialBufferAttribute.array, i * 16);
|
|
1045
|
+
else {
|
|
1046
|
+
dummy.position.copy(position);
|
|
1060
1047
|
}
|
|
1048
|
+
dummy.updateMatrix();
|
|
1061
1049
|
if (instance) {
|
|
1062
|
-
|
|
1050
|
+
instance.setMatrixAt(i, dummy.matrix);
|
|
1063
1051
|
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1052
|
+
dummy.matrix.toArray(initialBufferAttribute.array, i * 16);
|
|
1053
|
+
}
|
|
1054
|
+
if (instance) {
|
|
1055
|
+
checkUpdate(instance.instanceMatrix);
|
|
1056
|
+
}
|
|
1057
|
+
checkUpdate(initialBufferAttribute);
|
|
1058
|
+
return new THREE.InstancedBufferAttribute(initialBufferAttribute.array, initialBufferAttribute.itemSize).copy(initialBufferAttribute);
|
|
1067
1059
|
});
|
|
1068
1060
|
}
|
|
1069
1061
|
const defaultOptions = {
|
|
@@ -1077,31 +1069,42 @@ class NgtsSampler {
|
|
|
1077
1069
|
this.parameters = omit(this.options, ['weight', 'transform', 'count']);
|
|
1078
1070
|
// NOTE: this could have been a viewChild.required, but we need to _try_ to consume
|
|
1079
1071
|
// this Signal earlier than when a viewChild.required would resolve.
|
|
1080
|
-
this.groupRef = viewChild('group');
|
|
1072
|
+
this.groupRef = viewChild.required('group');
|
|
1073
|
+
this.count = pick(this.options, 'count');
|
|
1074
|
+
this.weight = pick(this.options, 'weight');
|
|
1075
|
+
this.transform = pick(this.options, 'transform');
|
|
1081
1076
|
extend({ Group });
|
|
1082
|
-
const
|
|
1083
|
-
const group = this.groupRef()
|
|
1084
|
-
const
|
|
1085
|
-
if (!
|
|
1086
|
-
return
|
|
1087
|
-
const
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1077
|
+
const meshToSample = computed(() => {
|
|
1078
|
+
const group = this.groupRef().nativeElement;
|
|
1079
|
+
const instanceState = getInstanceState(group);
|
|
1080
|
+
if (!instanceState)
|
|
1081
|
+
return null;
|
|
1082
|
+
const mesh = resolveRef(this.mesh());
|
|
1083
|
+
if (mesh)
|
|
1084
|
+
return mesh;
|
|
1085
|
+
const objects = instanceState.objects();
|
|
1086
|
+
return objects.find((c) => is.three(c, 'isMesh'));
|
|
1087
|
+
});
|
|
1088
|
+
const instancedMeshToSample = computed(() => {
|
|
1089
|
+
const group = this.groupRef().nativeElement;
|
|
1090
|
+
const instanceState = getInstanceState(group);
|
|
1091
|
+
if (!instanceState)
|
|
1092
|
+
return null;
|
|
1093
|
+
const instances = resolveRef(this.instances());
|
|
1094
|
+
if (instances)
|
|
1095
|
+
return instances;
|
|
1096
|
+
const objects = instanceState.objects();
|
|
1097
|
+
return objects.find((c) => !!Object.getOwnPropertyDescriptor(c, 'instanceMatrix'));
|
|
1093
1098
|
});
|
|
1094
|
-
const meshToSample = pick(sampleState, 'mesh');
|
|
1095
|
-
const instancedToSample = pick(sampleState, 'instanced');
|
|
1096
1099
|
// NOTE: because injectSurfaceSampler returns a computed, we need to consume
|
|
1097
1100
|
// this computed in a Reactive Context (an effect) to ensure the inner logic of
|
|
1098
1101
|
// injectSurfaceSampler is run properly.
|
|
1099
|
-
const sampler =
|
|
1100
|
-
count: this.
|
|
1101
|
-
transform: this.
|
|
1102
|
-
weight: this.
|
|
1103
|
-
|
|
1104
|
-
})
|
|
1102
|
+
const sampler = surfaceSampler(meshToSample, {
|
|
1103
|
+
count: this.count,
|
|
1104
|
+
transform: this.transform,
|
|
1105
|
+
weight: this.weight,
|
|
1106
|
+
instancedMesh: instancedMeshToSample,
|
|
1107
|
+
});
|
|
1105
1108
|
effect(sampler);
|
|
1106
1109
|
}
|
|
1107
1110
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtsSampler, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
@@ -1125,9 +1128,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImpor
|
|
|
1125
1128
|
}]
|
|
1126
1129
|
}], ctorParameters: () => [] });
|
|
1127
1130
|
|
|
1128
|
-
const tV0 = new Vector3();
|
|
1129
|
-
const tV1 = new Vector3();
|
|
1130
|
-
const tV2 = new Vector3();
|
|
1131
|
+
const tV0 = new THREE.Vector3();
|
|
1132
|
+
const tV1 = new THREE.Vector3();
|
|
1133
|
+
const tV2 = new THREE.Vector3();
|
|
1131
1134
|
function getPoint2(point3, camera, size) {
|
|
1132
1135
|
const widthHalf = size.width / 2;
|
|
1133
1136
|
const heightHalf = size.height / 2;
|
|
@@ -1157,5 +1160,5 @@ function calculateScaleFactor(point3, radiusPx, camera, size) {
|
|
|
1157
1160
|
* Generated bundle index. Do not edit.
|
|
1158
1161
|
*/
|
|
1159
1162
|
|
|
1160
|
-
export { LinearEncoding, NgtsBakeShadows, NgtsComputedAttribute, NgtsDecal, NgtsFBO, NgtsHTML, NgtsHTMLContent, NgtsIntersect, NgtsPreload, NgtsSampler, calculateScaleFactor, getVersion, injectAnimations, injectDepthBuffer, injectFBO, injectIntersect,
|
|
1163
|
+
export { LinearEncoding, NgtsBakeShadows, NgtsComputedAttribute, NgtsDecal, NgtsFBO, NgtsHTML, NgtsHTMLContent, NgtsHTMLDeclarations, NgtsIntersect, NgtsPreload, NgtsSampler, calculateScaleFactor, getVersion, injectAnimations, injectDepthBuffer, injectFBO, injectIntersect, sRGBEncoding, setUpdateRange, surfaceSampler };
|
|
1161
1164
|
//# sourceMappingURL=angular-three-soba-misc.mjs.map
|