angular-three-soba 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/abstractions/lib/catmull-rom-line.d.ts +148 -148
- package/abstractions/lib/edges.d.ts +166 -166
- package/abstractions/lib/grid.d.ts +30 -30
- package/abstractions/lib/line.d.ts +10 -9
- package/abstractions/lib/prism-geometry.d.ts +4 -4
- package/abstractions/lib/rounded-box.d.ts +3 -3
- package/abstractions/lib/text-3d.d.ts +38 -38
- package/abstractions/lib/text.d.ts +2 -3
- package/cameras/lib/cube-camera.d.ts +2 -2
- package/cameras/lib/orthographic-camera.d.ts +7 -8
- package/cameras/lib/perspective-camera.d.ts +2 -3
- package/controls/lib/camera-controls.d.ts +1 -1
- package/controls/lib/orbit-controls.d.ts +1 -1
- package/esm2022/abstractions/lib/billboard.mjs +3 -3
- package/esm2022/abstractions/lib/catmull-rom-line.mjs +3 -3
- package/esm2022/abstractions/lib/cubic-bezier-line.mjs +3 -3
- package/esm2022/abstractions/lib/edges.mjs +30 -34
- package/esm2022/abstractions/lib/gradient-texture.mjs +3 -3
- package/esm2022/abstractions/lib/grid.mjs +3 -3
- package/esm2022/abstractions/lib/helper.mjs +18 -20
- package/esm2022/abstractions/lib/line.mjs +25 -28
- package/esm2022/abstractions/lib/prism-geometry.mjs +3 -3
- package/esm2022/abstractions/lib/quadratic-bezier-line.mjs +3 -3
- package/esm2022/abstractions/lib/rounded-box.mjs +11 -17
- package/esm2022/abstractions/lib/text-3d.mjs +14 -17
- package/esm2022/abstractions/lib/text.mjs +11 -16
- package/esm2022/cameras/lib/camera-content.mjs +3 -3
- package/esm2022/cameras/lib/cube-camera.mjs +18 -27
- package/esm2022/cameras/lib/orthographic-camera.mjs +20 -20
- package/esm2022/cameras/lib/perspective-camera.mjs +21 -21
- package/esm2022/controls/lib/camera-controls.mjs +3 -3
- package/esm2022/controls/lib/orbit-controls.mjs +3 -3
- package/esm2022/controls/lib/scroll-controls.mjs +124 -130
- package/esm2022/gizmos/lib/gizmo-helper/gizmo-helper.mjs +6 -6
- package/esm2022/gizmos/lib/gizmo-helper/gizmo-viewcube.mjs +12 -12
- package/esm2022/gizmos/lib/gizmo-helper/gizmo-viewport.mjs +9 -9
- package/esm2022/gizmos/lib/pivot-controls/axis-arrow.mjs +6 -4
- package/esm2022/gizmos/lib/pivot-controls/axis-rotator.mjs +3 -3
- package/esm2022/gizmos/lib/pivot-controls/pivot-controls.mjs +44 -47
- package/esm2022/gizmos/lib/pivot-controls/plane-slider.mjs +3 -3
- package/esm2022/gizmos/lib/pivot-controls/scaling-sphere.mjs +3 -3
- package/esm2022/gizmos/lib/transform-controls.mjs +3 -3
- package/esm2022/loaders/lib/loader.mjs +3 -3
- package/esm2022/materials/lib/custom-shader-material.mjs +8 -12
- package/esm2022/materials/lib/mesh-distort-material.mjs +3 -3
- package/esm2022/materials/lib/mesh-reflector-material.mjs +11 -15
- package/esm2022/materials/lib/mesh-refraction-material.mjs +26 -30
- package/esm2022/materials/lib/mesh-transmission-material.mjs +3 -3
- package/esm2022/materials/lib/mesh-wobble-material.mjs +3 -3
- package/esm2022/materials/lib/point-material.mjs +3 -3
- package/esm2022/misc/lib/bake-shadows.mjs +8 -10
- package/esm2022/misc/lib/computed-attribute.mjs +15 -19
- package/esm2022/misc/lib/decal.mjs +56 -53
- package/esm2022/misc/lib/fbo.mjs +10 -10
- package/esm2022/misc/lib/html/html-content.mjs +62 -67
- package/esm2022/misc/lib/html/html.mjs +3 -3
- package/esm2022/misc/lib/intersect.mjs +6 -9
- package/esm2022/misc/lib/sampler.mjs +42 -42
- package/esm2022/performances/lib/adaptive-dpr.mjs +29 -35
- package/esm2022/performances/lib/adaptive-events.mjs +12 -16
- package/esm2022/performances/lib/detailed.mjs +14 -18
- package/esm2022/performances/lib/instances/instances.mjs +16 -22
- package/esm2022/performances/lib/points/points.mjs +19 -25
- package/esm2022/performances/lib/segments/segments.mjs +11 -14
- package/esm2022/shaders/lib/mesh-refraction-material.mjs +1 -1
- package/esm2022/staging/index.mjs +3 -2
- package/esm2022/staging/lib/accumulative-shadows.mjs +19 -21
- package/esm2022/staging/lib/backdrop.mjs +19 -23
- package/esm2022/staging/lib/bb-anchor.mjs +3 -3
- package/esm2022/staging/lib/bounds.mjs +39 -43
- package/esm2022/staging/lib/camera-shake.mjs +14 -18
- package/esm2022/staging/lib/caustics.mjs +24 -28
- package/esm2022/staging/lib/center.mjs +28 -32
- package/esm2022/staging/lib/contact-shadows.mjs +3 -3
- package/esm2022/staging/lib/environment/environment.mjs +338 -0
- package/esm2022/staging/lib/environment/inject-environment.mjs +184 -0
- package/esm2022/staging/lib/float.mjs +3 -3
- package/esm2022/staging/lib/lightformer.mjs +18 -22
- package/esm2022/staging/lib/mask.mjs +8 -12
- package/esm2022/staging/lib/matcap-texture.mjs +9 -11
- package/esm2022/staging/lib/normal-texture.mjs +9 -11
- package/esm2022/staging/lib/randomized-lights.mjs +9 -13
- package/esm2022/staging/lib/render-texture.mjs +19 -20
- package/esm2022/staging/lib/sky.mjs +3 -3
- package/esm2022/staging/lib/spot-light.mjs +32 -40
- package/esm2022/staging/lib/stage.mjs +13 -17
- package/esm2022/stats/lib/stats.mjs +21 -27
- package/fesm2022/angular-three-soba-abstractions.mjs +119 -138
- package/fesm2022/angular-three-soba-abstractions.mjs.map +1 -1
- package/fesm2022/angular-three-soba-cameras.mjs +57 -64
- package/fesm2022/angular-three-soba-cameras.mjs.map +1 -1
- package/fesm2022/angular-three-soba-controls.mjs +129 -135
- package/fesm2022/angular-three-soba-controls.mjs.map +1 -1
- package/fesm2022/angular-three-soba-gizmos.mjs +87 -88
- package/fesm2022/angular-three-soba-gizmos.mjs.map +1 -1
- package/fesm2022/angular-three-soba-loaders.mjs +3 -3
- package/fesm2022/angular-three-soba-materials.mjs +52 -62
- package/fesm2022/angular-three-soba-materials.mjs.map +1 -1
- package/fesm2022/angular-three-soba-misc.mjs +188 -195
- package/fesm2022/angular-three-soba-misc.mjs.map +1 -1
- package/fesm2022/angular-three-soba-performances.mjs +90 -114
- package/fesm2022/angular-three-soba-performances.mjs.map +1 -1
- package/fesm2022/angular-three-soba-shaders.mjs.map +1 -1
- package/fesm2022/angular-three-soba-staging.mjs +427 -430
- package/fesm2022/angular-three-soba-staging.mjs.map +1 -1
- package/fesm2022/angular-three-soba-stats.mjs +20 -26
- package/fesm2022/angular-three-soba-stats.mjs.map +1 -1
- package/materials/lib/custom-shader-material.d.ts +3 -3
- package/materials/lib/mesh-refraction-material.d.ts +3 -3
- package/materials/lib/mesh-transmission-material.d.ts +1 -1
- package/misc/lib/computed-attribute.d.ts +5 -5
- package/misc/lib/decal.d.ts +5 -5
- package/misc/lib/html/html-content.d.ts +6 -6
- package/misc/lib/html/html.d.ts +1 -1
- package/misc/lib/sampler.d.ts +2 -4
- package/package.json +12 -12
- package/performances/lib/instances/instances.d.ts +11 -11
- package/performances/lib/points/points.d.ts +20 -20
- package/performances/lib/segments/segments.d.ts +4 -4
- package/shaders/lib/mesh-refraction-material.d.ts +2 -5
- package/staging/index.d.ts +2 -1
- package/staging/lib/camera-shake.d.ts +0 -1
- package/staging/lib/caustics.d.ts +1 -1
- package/staging/lib/center.d.ts +2 -2
- package/staging/lib/contact-shadows.d.ts +1 -1
- package/staging/lib/{environment.d.ts → environment/environment.d.ts} +20 -49
- package/staging/lib/environment/inject-environment.d.ts +33 -0
- package/staging/lib/lightformer.d.ts +1 -1
- package/staging/lib/mask.d.ts +1 -1
- package/staging/lib/matcap-texture.d.ts +0 -1
- package/staging/lib/normal-texture.d.ts +0 -1
- package/staging/lib/render-texture.d.ts +1 -1
- package/staging/lib/sky.d.ts +1 -1
- package/staging/lib/spot-light.d.ts +2 -2
- package/staging/lib/stage.d.ts +7 -6
- package/esm2022/staging/lib/environment.mjs +0 -481
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { computed, isSignal, signal, effect, untracked, Directive, input, viewChild,
|
|
2
|
+
import { computed, isSignal, signal, effect, untracked, Directive, input, viewChild, Component, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, inject, DestroyRef, TemplateRef, ViewContainerRef, afterNextRender, output, Renderer2, model, ElementRef } from '@angular/core';
|
|
3
3
|
import { injectBeforeRender, resolveRef, injectStore, getLocalState, NgtArgs, omit, pick, extend, applyProps, is, NgtHTML, addEffect, addAfterEffect, checkUpdate } from 'angular-three';
|
|
4
4
|
import { assertInjector } from 'ngxtension/assert-injector';
|
|
5
5
|
import { AnimationMixer, BufferAttribute, REVISION, Mesh, BoxGeometry, MeshNormalMaterial, AxesHelper, Vector3, Euler, Object3D, WebGLRenderTarget, LinearFilter, HalfFloatType, DepthTexture, FloatType, DepthFormat, UnsignedShortType, DoubleSide, Group, PlaneGeometry, ShaderMaterial, Vector2, OrthographicCamera, PerspectiveCamera, InstancedBufferAttribute, Color } from 'three';
|
|
6
|
-
import { injectAutoEffect } from 'ngxtension/auto-effect';
|
|
7
6
|
import { mergeInputs } from 'ngxtension/inject-inputs';
|
|
8
7
|
import { DecalGeometry, MeshSurfaceSampler } from 'three-stdlib';
|
|
9
8
|
import { NgTemplateOutlet } from '@angular/common';
|
|
@@ -77,22 +76,21 @@ function injectAnimations(animations, object, { injector } = {}) {
|
|
|
77
76
|
|
|
78
77
|
class NgtsBakeShadows {
|
|
79
78
|
constructor() {
|
|
80
|
-
const autoEffect = injectAutoEffect();
|
|
81
79
|
const store = injectStore();
|
|
82
80
|
const gl = store.select('gl');
|
|
83
|
-
|
|
81
|
+
effect((onCleanup) => {
|
|
84
82
|
const _gl = gl();
|
|
85
83
|
_gl.shadowMap.autoUpdate = false;
|
|
86
84
|
_gl.shadowMap.needsUpdate = true;
|
|
87
|
-
|
|
85
|
+
onCleanup(() => {
|
|
88
86
|
_gl.shadowMap.autoUpdate = _gl.shadowMap.needsUpdate = true;
|
|
89
|
-
};
|
|
87
|
+
});
|
|
90
88
|
});
|
|
91
89
|
}
|
|
92
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
93
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.
|
|
90
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsBakeShadows, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
91
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.4", type: NgtsBakeShadows, isStandalone: true, selector: "ngts-bake-shadows", ngImport: i0 }); }
|
|
94
92
|
}
|
|
95
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
93
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsBakeShadows, decorators: [{
|
|
96
94
|
type: Directive,
|
|
97
95
|
args: [{ standalone: true, selector: 'ngts-bake-shadows' }]
|
|
98
96
|
}], ctorParameters: () => [] });
|
|
@@ -109,29 +107,26 @@ class NgtsComputedAttribute {
|
|
|
109
107
|
this.options = input({});
|
|
110
108
|
this.bufferAttribute = new BufferAttribute(new Float32Array(0), 1);
|
|
111
109
|
this.attributeRef = viewChild('attribute');
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const attribute = this.compute()(geometry);
|
|
123
|
-
bufferAttribute.copy(attribute);
|
|
124
|
-
});
|
|
110
|
+
effect(() => {
|
|
111
|
+
const bufferAttribute = this.attributeRef()?.nativeElement;
|
|
112
|
+
if (!bufferAttribute)
|
|
113
|
+
return;
|
|
114
|
+
const localState = getLocalState(bufferAttribute);
|
|
115
|
+
if (!localState)
|
|
116
|
+
return;
|
|
117
|
+
const geometry = bufferAttribute.parent ?? localState.parent();
|
|
118
|
+
const attribute = this.compute()(geometry);
|
|
119
|
+
bufferAttribute.copy(attribute);
|
|
125
120
|
});
|
|
126
121
|
}
|
|
127
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
128
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "18.2.
|
|
122
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsComputedAttribute, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
123
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "18.2.4", type: NgtsComputedAttribute, isStandalone: true, selector: "ngts-computed-attribute", inputs: { compute: { classPropertyName: "compute", publicName: "compute", isSignal: true, isRequired: true, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "attributeRef", first: true, predicate: ["attribute"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
129
124
|
<ngt-primitive #attribute *args="[bufferAttribute]" [attach]="['attributes', name()]" [parameters]="options()">
|
|
130
125
|
<ng-content />
|
|
131
126
|
</ngt-primitive>
|
|
132
127
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "ng-template[args]", inputs: ["args"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
133
128
|
}
|
|
134
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
129
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsComputedAttribute, decorators: [{
|
|
135
130
|
type: Component,
|
|
136
131
|
args: [{
|
|
137
132
|
selector: 'ngts-computed-attribute',
|
|
@@ -179,58 +174,62 @@ class NgtsDecal {
|
|
|
179
174
|
this.rotation = pick(this.options, 'rotation');
|
|
180
175
|
this.scale = pick(this.options, 'scale');
|
|
181
176
|
extend({ Mesh, BoxGeometry, MeshNormalMaterial, AxesHelper });
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
177
|
+
effect((onCleanup) => {
|
|
178
|
+
const thisMesh = this.meshRef().nativeElement;
|
|
179
|
+
const localState = getLocalState(thisMesh);
|
|
180
|
+
if (!localState)
|
|
181
|
+
return;
|
|
182
|
+
const parent = resolveRef(this.mesh()) || localState.parent();
|
|
183
|
+
if (parent && !parent.isMesh) {
|
|
184
|
+
throw new Error('<ngts-decal> must have a Mesh as parent or specify its "mesh" input');
|
|
185
|
+
}
|
|
186
|
+
if (!parent)
|
|
187
|
+
return;
|
|
188
|
+
const parentLocalState = getLocalState(parent);
|
|
189
|
+
if (!parentLocalState)
|
|
190
|
+
return;
|
|
191
|
+
// track parent's children
|
|
192
|
+
const parentNonObjects = parentLocalState.nonObjects();
|
|
193
|
+
if (!parentNonObjects || !parentNonObjects.length) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
// if parent geometry doesn't have its attributes populated properly, we skip
|
|
197
|
+
if (!parent.geometry?.attributes?.['position']) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const [position, rotation, scale] = [this.position(), this.rotation(), this.scale()];
|
|
201
|
+
const state = { position: new Vector3(), rotation: new Euler(), scale: new Vector3(1, 1, 1) };
|
|
202
|
+
applyProps(state, { position, scale });
|
|
203
|
+
// zero out the parents matrix world for this operation
|
|
204
|
+
const matrixWorld = parent.matrixWorld.clone();
|
|
205
|
+
parent.matrixWorld.identity();
|
|
206
|
+
if (!rotation || typeof rotation === 'number') {
|
|
207
|
+
const o = new Object3D();
|
|
208
|
+
o.position.copy(state.position);
|
|
209
|
+
o.lookAt(parent.position);
|
|
210
|
+
if (typeof rotation === 'number')
|
|
211
|
+
o.rotateZ(rotation);
|
|
212
|
+
applyProps(state, { rotation: o.rotation });
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
applyProps(state, { rotation });
|
|
216
|
+
}
|
|
217
|
+
thisMesh.geometry = new DecalGeometry(parent, state.position, state.rotation, state.scale);
|
|
218
|
+
const helper = this.helperRef()?.nativeElement;
|
|
219
|
+
if (helper) {
|
|
220
|
+
applyProps(helper, state);
|
|
221
|
+
// Prevent the helpers from blocking rays
|
|
222
|
+
helper.traverse((child) => (child.raycast = () => null));
|
|
223
|
+
}
|
|
224
|
+
// Reset parents matrix-world
|
|
225
|
+
parent.matrixWorld = matrixWorld;
|
|
226
|
+
onCleanup(() => {
|
|
227
|
+
thisMesh.geometry.dispose();
|
|
229
228
|
});
|
|
230
229
|
});
|
|
231
230
|
}
|
|
232
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
233
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.
|
|
231
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsDecal, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
232
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.4", type: NgtsDecal, isStandalone: true, selector: "ngts-decal", inputs: { mesh: { classPropertyName: "mesh", publicName: "mesh", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "meshRef", first: true, predicate: ["mesh"], descendants: true, isSignal: true }, { propertyName: "helperRef", first: true, predicate: ["helper"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
234
233
|
<ngt-mesh #mesh [parameters]="parameters()">
|
|
235
234
|
<ngt-value [rawValue]="true" attach="material.transparent" />
|
|
236
235
|
<ngt-value [rawValue]="true" attach="material.polygonOffset" />
|
|
@@ -252,7 +251,7 @@ class NgtsDecal {
|
|
|
252
251
|
</ngt-mesh>
|
|
253
252
|
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
254
253
|
}
|
|
255
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
254
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsDecal, decorators: [{
|
|
256
255
|
type: Component,
|
|
257
256
|
args: [{
|
|
258
257
|
selector: 'ngts-decal',
|
|
@@ -353,12 +352,12 @@ class NgtsFBO {
|
|
|
353
352
|
this.template = inject(TemplateRef);
|
|
354
353
|
this.viewContainerRef = inject(ViewContainerRef);
|
|
355
354
|
let ref;
|
|
356
|
-
const
|
|
355
|
+
const fboTarget = injectFBO(() => {
|
|
356
|
+
const { width, height, ...settings } = this.fbo();
|
|
357
|
+
return { width, height, settings };
|
|
358
|
+
});
|
|
357
359
|
afterNextRender(() => {
|
|
358
|
-
|
|
359
|
-
const { width, height, ...settings } = this.fbo();
|
|
360
|
-
return { width, height, settings };
|
|
361
|
-
}, { injector });
|
|
360
|
+
// TODO: double check if we need untracked
|
|
362
361
|
untracked(() => {
|
|
363
362
|
ref = this.viewContainerRef.createEmbeddedView(this.template, { $implicit: fboTarget });
|
|
364
363
|
ref.detectChanges();
|
|
@@ -371,10 +370,10 @@ class NgtsFBO {
|
|
|
371
370
|
static ngTemplateContextGuard(_, ctx) {
|
|
372
371
|
return true;
|
|
373
372
|
}
|
|
374
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
375
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.
|
|
373
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsFBO, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
374
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.4", type: NgtsFBO, isStandalone: true, selector: "ng-template[fbo]", inputs: { fbo: { classPropertyName: "fbo", publicName: "fbo", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
376
375
|
}
|
|
377
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
376
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsFBO, decorators: [{
|
|
378
377
|
type: Directive,
|
|
379
378
|
args: [{ selector: 'ng-template[fbo]', standalone: true }]
|
|
380
379
|
}], ctorParameters: () => [] });
|
|
@@ -485,8 +484,8 @@ class NgtsHTML {
|
|
|
485
484
|
this.DoubleSide = DoubleSide;
|
|
486
485
|
extend({ Group, Mesh, PlaneGeometry, ShaderMaterial });
|
|
487
486
|
}
|
|
488
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
489
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.
|
|
487
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsHTML, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
488
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.4", 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: `
|
|
490
489
|
<ngt-group #group [parameters]="parameters()">
|
|
491
490
|
@if (occlude() && !isRaycastOcclusion()) {
|
|
492
491
|
<ngt-mesh #occlusionMesh [castShadow]="castShadow()" [receiveShadow]="receiveShadow()">
|
|
@@ -507,7 +506,7 @@ class NgtsHTML {
|
|
|
507
506
|
<ng-content />
|
|
508
507
|
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
509
508
|
}
|
|
510
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
509
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsHTML, decorators: [{
|
|
511
510
|
type: Component,
|
|
512
511
|
args: [{
|
|
513
512
|
selector: 'ngts-html',
|
|
@@ -654,71 +653,67 @@ class NgtsHTMLContent extends NgtHTML {
|
|
|
654
653
|
return parent;
|
|
655
654
|
return (this.events().connected || this.gl().domElement.parentNode);
|
|
656
655
|
});
|
|
657
|
-
const autoEffect = injectAutoEffect();
|
|
658
656
|
const renderer = inject(Renderer2);
|
|
659
657
|
let isMeshSizeSet = false;
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
target.removeChild(hostEl);
|
|
714
|
-
};
|
|
715
|
-
});
|
|
716
|
-
autoEffect(() => {
|
|
717
|
-
this.options();
|
|
718
|
-
this.html.options();
|
|
719
|
-
isMeshSizeSet = false;
|
|
658
|
+
effect(() => {
|
|
659
|
+
const [occlude, canvasEl, zIndexRange] = [
|
|
660
|
+
this.html.occlude(),
|
|
661
|
+
untracked(this.gl).domElement,
|
|
662
|
+
untracked(this.zIndexRange),
|
|
663
|
+
];
|
|
664
|
+
if (occlude && occlude === 'blending') {
|
|
665
|
+
renderer.setStyle(canvasEl, 'z-index', `${Math.floor(zIndexRange[0] / 2)}`);
|
|
666
|
+
renderer.setStyle(canvasEl, 'position', 'absolute');
|
|
667
|
+
renderer.setStyle(canvasEl, 'pointer-events', 'none');
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
renderer.removeStyle(canvasEl, 'z-index');
|
|
671
|
+
renderer.removeStyle(canvasEl, 'position');
|
|
672
|
+
renderer.removeStyle(canvasEl, 'pointer-events');
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
effect((onCleanup) => {
|
|
676
|
+
const [transform, target, hostEl, prepend, scene, calculatePosition, group, size, camera] = [
|
|
677
|
+
this.html.transform(),
|
|
678
|
+
this.target(),
|
|
679
|
+
this.host.nativeElement,
|
|
680
|
+
untracked(this.prepend),
|
|
681
|
+
untracked(this.scene),
|
|
682
|
+
untracked(this.calculatePosition),
|
|
683
|
+
untracked(this.html.groupRef).nativeElement,
|
|
684
|
+
untracked(this.size),
|
|
685
|
+
untracked(this.camera),
|
|
686
|
+
];
|
|
687
|
+
scene.updateMatrixWorld();
|
|
688
|
+
renderer.setStyle(hostEl, 'position', 'absolute');
|
|
689
|
+
renderer.setStyle(hostEl, 'top', '0');
|
|
690
|
+
renderer.setStyle(hostEl, 'left', '0');
|
|
691
|
+
if (transform) {
|
|
692
|
+
renderer.setStyle(hostEl, 'pointer-events', 'none');
|
|
693
|
+
renderer.setStyle(hostEl, 'overflow', 'hidden');
|
|
694
|
+
renderer.removeStyle(hostEl, 'transform');
|
|
695
|
+
renderer.removeStyle(hostEl, 'transform-origin');
|
|
696
|
+
}
|
|
697
|
+
else {
|
|
698
|
+
const vec = calculatePosition(group, camera, size);
|
|
699
|
+
renderer.setStyle(hostEl, 'transform', `translate3d(${vec[0]}px,${vec[1]}px,0)`);
|
|
700
|
+
renderer.setStyle(hostEl, 'transform-origin', '0 0');
|
|
701
|
+
renderer.removeStyle(hostEl, 'pointer-events');
|
|
702
|
+
renderer.removeStyle(hostEl, 'overflow');
|
|
703
|
+
}
|
|
704
|
+
if (prepend)
|
|
705
|
+
target.prepend(hostEl);
|
|
706
|
+
else
|
|
707
|
+
target.appendChild(hostEl);
|
|
708
|
+
onCleanup(() => {
|
|
709
|
+
if (target)
|
|
710
|
+
target.removeChild(hostEl);
|
|
720
711
|
});
|
|
721
712
|
});
|
|
713
|
+
effect(() => {
|
|
714
|
+
const _ = [this.options(), this.html.options()];
|
|
715
|
+
isMeshSizeSet = false;
|
|
716
|
+
});
|
|
722
717
|
let visible = true;
|
|
723
718
|
let oldZoom = 0;
|
|
724
719
|
let oldPosition = [0, 0];
|
|
@@ -847,8 +842,8 @@ class NgtsHTMLContent extends NgtHTML {
|
|
|
847
842
|
}
|
|
848
843
|
});
|
|
849
844
|
}
|
|
850
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
851
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.
|
|
845
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsHTMLContent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
846
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.4", type: NgtsHTMLContent, isStandalone: true, selector: "[ngtsHTMLContent]", inputs: { options: { classPropertyName: "options", publicName: "ngtsHTMLContent", 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: `
|
|
852
847
|
@if (html.transform()) {
|
|
853
848
|
<div
|
|
854
849
|
#transformOuter
|
|
@@ -883,7 +878,7 @@ class NgtsHTMLContent extends NgtHTML {
|
|
|
883
878
|
</ng-template>
|
|
884
879
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
885
880
|
}
|
|
886
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
881
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsHTMLContent, decorators: [{
|
|
887
882
|
type: Component,
|
|
888
883
|
args: [{
|
|
889
884
|
selector: '[ngtsHTMLContent]',
|
|
@@ -963,39 +958,36 @@ class NgtsIntersect {
|
|
|
963
958
|
constructor() {
|
|
964
959
|
this.intersect = model(false);
|
|
965
960
|
const host = inject(ElementRef);
|
|
966
|
-
|
|
967
|
-
afterNextRender(() => {
|
|
968
|
-
injectIntersect(() => host, { source: this.intersect, injector });
|
|
969
|
-
});
|
|
961
|
+
injectIntersect(() => host, { source: this.intersect });
|
|
970
962
|
}
|
|
971
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
972
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.
|
|
963
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsIntersect, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
964
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.4", type: NgtsIntersect, isStandalone: true, selector: "[intersect]", inputs: { intersect: { classPropertyName: "intersect", publicName: "intersect", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { intersect: "intersectChange" }, ngImport: i0 }); }
|
|
973
965
|
}
|
|
974
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
966
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsIntersect, decorators: [{
|
|
975
967
|
type: Directive,
|
|
976
968
|
args: [{ standalone: true, selector: '[intersect]' }]
|
|
977
969
|
}], ctorParameters: () => [] });
|
|
978
970
|
|
|
979
971
|
function injectSurfaceSampler(mesh, options = () => ({}), { injector } = {}) {
|
|
980
972
|
return assertInjector(injectSurfaceSampler, injector, () => {
|
|
981
|
-
const
|
|
973
|
+
const initialBufferAttribute = (() => {
|
|
982
974
|
const arr = Array.from({ length: options().count ?? 16 }, () => [
|
|
983
975
|
1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1,
|
|
984
976
|
]).flat();
|
|
985
977
|
return new InstancedBufferAttribute(Float32Array.from(arr), 16);
|
|
986
|
-
})()
|
|
987
|
-
|
|
978
|
+
})();
|
|
979
|
+
return computed(() => {
|
|
988
980
|
const currentMesh = resolveRef(mesh());
|
|
989
981
|
if (!currentMesh)
|
|
990
|
-
return;
|
|
982
|
+
return initialBufferAttribute;
|
|
991
983
|
const localState = getLocalState(currentMesh);
|
|
992
984
|
if (!localState)
|
|
993
|
-
return;
|
|
985
|
+
return initialBufferAttribute;
|
|
994
986
|
const nonObjects = localState.nonObjects();
|
|
995
987
|
if (!nonObjects ||
|
|
996
988
|
!nonObjects.length ||
|
|
997
989
|
nonObjects.every((nonObject) => !nonObject.isBufferGeometry)) {
|
|
998
|
-
return;
|
|
990
|
+
return initialBufferAttribute;
|
|
999
991
|
}
|
|
1000
992
|
const sampler = new MeshSurfaceSampler(currentMesh);
|
|
1001
993
|
const { weight, count = 16, transform, instanceMesh } = options();
|
|
@@ -1021,15 +1013,14 @@ function injectSurfaceSampler(mesh, options = () => ({}), { injector } = {}) {
|
|
|
1021
1013
|
if (instance) {
|
|
1022
1014
|
instance.setMatrixAt(i, dummy.matrix);
|
|
1023
1015
|
}
|
|
1024
|
-
dummy.matrix.toArray(
|
|
1016
|
+
dummy.matrix.toArray(initialBufferAttribute.array, i * 16);
|
|
1025
1017
|
}
|
|
1026
1018
|
if (instance) {
|
|
1027
1019
|
checkUpdate(instance.instanceMatrix);
|
|
1028
1020
|
}
|
|
1029
|
-
checkUpdate(
|
|
1030
|
-
|
|
1031
|
-
}
|
|
1032
|
-
return buffer.asReadonly();
|
|
1021
|
+
checkUpdate(initialBufferAttribute);
|
|
1022
|
+
return new InstancedBufferAttribute(initialBufferAttribute.array, initialBufferAttribute.itemSize).copy(initialBufferAttribute);
|
|
1023
|
+
});
|
|
1033
1024
|
});
|
|
1034
1025
|
}
|
|
1035
1026
|
const defaultOptions = {
|
|
@@ -1041,41 +1032,43 @@ class NgtsSampler {
|
|
|
1041
1032
|
this.instances = input(null);
|
|
1042
1033
|
this.options = input(defaultOptions, { transform: mergeInputs(defaultOptions) });
|
|
1043
1034
|
this.parameters = omit(this.options, ['weight', 'transform', 'count']);
|
|
1044
|
-
this
|
|
1045
|
-
this.
|
|
1046
|
-
this.
|
|
1035
|
+
// NOTE: this could have been a viewChild.required, but we need to _try_ to consume
|
|
1036
|
+
// this Signal earlier than when a viewChild.required would resolve.
|
|
1037
|
+
this.groupRef = viewChild('group');
|
|
1047
1038
|
extend({ Group });
|
|
1048
|
-
const
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
localState
|
|
1060
|
-
.objects()
|
|
1061
|
-
.find((c) => !!Object.getOwnPropertyDescriptor(c, 'instanceMatrix')));
|
|
1062
|
-
}, { allowSignalWrites: true });
|
|
1063
|
-
injectSurfaceSampler(this.meshToSample, () => ({
|
|
1064
|
-
count: this.options().count,
|
|
1065
|
-
transform: this.options().transform,
|
|
1066
|
-
weight: this.options().weight,
|
|
1067
|
-
instanceMesh: this.instancedToSample(),
|
|
1068
|
-
}), { injector });
|
|
1039
|
+
const sampleState = computed(() => {
|
|
1040
|
+
const group = this.groupRef()?.nativeElement;
|
|
1041
|
+
const localState = getLocalState(group);
|
|
1042
|
+
if (!localState)
|
|
1043
|
+
return { mesh: null, instanced: null };
|
|
1044
|
+
const [mesh, instances] = [resolveRef(this.mesh()), resolveRef(this.instances())];
|
|
1045
|
+
const objects = localState.objects();
|
|
1046
|
+
return {
|
|
1047
|
+
mesh: mesh ?? objects.find((c) => c.type === 'Mesh'),
|
|
1048
|
+
instanced: instances ?? objects.find((c) => !!Object.getOwnPropertyDescriptor(c, 'instanceMatrix')),
|
|
1049
|
+
};
|
|
1069
1050
|
});
|
|
1051
|
+
const meshToSample = pick(sampleState, 'mesh');
|
|
1052
|
+
const instancedToSample = pick(sampleState, 'instanced');
|
|
1053
|
+
// NOTE: because injectSurfaceSampler returns a computed, we need to consume
|
|
1054
|
+
// this computed in a Reactive Context (an effect) to ensure the inner logic of
|
|
1055
|
+
// injectSurfaceSampler is run properly.
|
|
1056
|
+
const sampler = injectSurfaceSampler(meshToSample, () => ({
|
|
1057
|
+
count: this.options().count,
|
|
1058
|
+
transform: this.options().transform,
|
|
1059
|
+
weight: this.options().weight,
|
|
1060
|
+
instanceMesh: instancedToSample(),
|
|
1061
|
+
}));
|
|
1062
|
+
effect(sampler);
|
|
1070
1063
|
}
|
|
1071
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
1072
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "18.2.
|
|
1064
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsSampler, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1065
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "18.2.4", type: NgtsSampler, isStandalone: true, selector: "ngts-sampler", inputs: { mesh: { classPropertyName: "mesh", publicName: "mesh", isSignal: true, isRequired: false, transformFunction: null }, instances: { classPropertyName: "instances", publicName: "instances", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "groupRef", first: true, predicate: ["group"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
1073
1066
|
<ngt-group #group [parameters]="parameters()">
|
|
1074
1067
|
<ng-content />
|
|
1075
1068
|
</ngt-group>
|
|
1076
1069
|
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1077
1070
|
}
|
|
1078
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
1071
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NgtsSampler, decorators: [{
|
|
1079
1072
|
type: Component,
|
|
1080
1073
|
args: [{
|
|
1081
1074
|
selector: 'ngts-sampler',
|