angular-three-soba 4.0.0-next.97 → 4.0.0-next.98
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 +55 -55
- package/abstractions/lib/edges.d.ts +55 -55
- package/abstractions/lib/helper.d.ts +6 -1
- package/abstractions/lib/line.d.ts +1 -1
- package/abstractions/lib/text-3d.d.ts +1 -1
- package/cameras/lib/cube-camera.d.ts +7 -2
- package/cameras/lib/orthographic-camera.d.ts +1 -1
- package/cameras/lib/perspective-camera.d.ts +1 -1
- package/fesm2022/angular-three-soba-abstractions.mjs +16 -11
- package/fesm2022/angular-three-soba-abstractions.mjs.map +1 -1
- package/fesm2022/angular-three-soba-cameras.mjs +16 -11
- package/fesm2022/angular-three-soba-cameras.mjs.map +1 -1
- package/fesm2022/angular-three-soba-controls.mjs +7 -7
- package/fesm2022/angular-three-soba-controls.mjs.map +1 -1
- package/fesm2022/angular-three-soba-gizmos.mjs +10 -10
- package/fesm2022/angular-three-soba-gizmos.mjs.map +1 -1
- package/fesm2022/angular-three-soba-loaders.mjs +186 -49
- package/fesm2022/angular-three-soba-loaders.mjs.map +1 -1
- package/fesm2022/angular-three-soba-materials.mjs +14 -14
- package/fesm2022/angular-three-soba-materials.mjs.map +1 -1
- package/fesm2022/angular-three-soba-misc.mjs +38 -18
- package/fesm2022/angular-three-soba-misc.mjs.map +1 -1
- package/fesm2022/angular-three-soba-performances.mjs +6 -6
- package/fesm2022/angular-three-soba-performances.mjs.map +1 -1
- package/fesm2022/angular-three-soba-staging.mjs +142 -54
- package/fesm2022/angular-three-soba-staging.mjs.map +1 -1
- package/gizmos/lib/pivot-controls/axis-arrow.d.ts +1 -1
- package/gizmos/lib/pivot-controls/axis-rotator.d.ts +1 -1
- package/gizmos/lib/pivot-controls/pivot-controls.d.ts +1 -1
- package/gizmos/lib/pivot-controls/plane-slider.d.ts +1 -1
- package/gizmos/lib/pivot-controls/scaling-sphere.d.ts +1 -1
- package/loaders/index.d.ts +4 -0
- package/loaders/lib/fbx-loader.d.ts +9 -1
- package/loaders/lib/fbx-resource.d.ts +7 -0
- package/loaders/lib/font-loader.d.ts +6 -20
- package/loaders/lib/font-resource.d.ts +28 -0
- package/loaders/lib/gltf-loader.d.ts +8 -0
- package/loaders/lib/gltf-resource.d.ts +32 -0
- package/loaders/lib/loader.d.ts +2 -2
- package/loaders/lib/progress.d.ts +6 -1
- package/loaders/lib/texture-loader.d.ts +8 -0
- package/loaders/lib/texture-resource.d.ts +10 -0
- package/materials/lib/custom-shader-material.d.ts +2 -2
- package/materials/lib/mesh-portal-material.d.ts +1 -1
- package/materials/lib/mesh-refraction-material.d.ts +1 -1
- package/materials/lib/mesh-transmission-material.d.ts +1 -1
- package/misc/lib/animations.d.ts +6 -1
- package/misc/lib/decal.d.ts +1 -1
- package/misc/lib/depth-buffer.d.ts +6 -1
- package/misc/lib/fbo.d.ts +7 -2
- package/misc/lib/intersect.d.ts +6 -1
- package/package.json +5 -5
- package/performances/lib/bvh.d.ts +1 -1
- package/performances/lib/instances/instances.d.ts +1 -1
- package/performances/lib/points/points.d.ts +1 -1
- package/performances/lib/segments/segments.d.ts +23 -23
- package/staging/index.d.ts +1 -0
- package/staging/lib/accumulative-shadows.d.ts +1 -1
- package/staging/lib/caustics.d.ts +1 -1
- package/staging/lib/contact-shadows.d.ts +1 -1
- package/staging/lib/environment/environment-resource.d.ts +35 -0
- package/staging/lib/environment/environment.d.ts +3 -3
- package/staging/lib/environment/inject-environment.d.ts +8 -24
- package/staging/lib/lightformer.d.ts +1 -1
- package/staging/lib/matcap-texture.d.ts +17 -4
- package/staging/lib/normal-texture.d.ts +20 -7
- package/staging/lib/render-texture.d.ts +1 -1
- package/staging/lib/spot-light.d.ts +4 -4
- package/staging/lib/stage.d.ts +1 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { input, viewChild, computed, effect, inject, DestroyRef, untracked, Component, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, signal, Directive, output, Injector, contentChild, TemplateRef, numberAttribute, ViewContainerRef } from '@angular/core';
|
|
3
3
|
import * as i1 from 'angular-three';
|
|
4
|
-
import { omit, injectStore, pick, extend, getInstanceState,
|
|
4
|
+
import { omit, injectStore, pick, extend, getInstanceState, beforeRender, checkUpdate, NgtArgs, vector3, is, resolveRef, loaderResource, applyProps, NgtPortal } from 'angular-three';
|
|
5
5
|
import { ProgressiveLightMap, SoftShadowMaterial, CausticsProjectionMaterial, createCausticsUpdate, SpotLightMaterial } from 'angular-three-soba/vanilla-exports';
|
|
6
6
|
import { mergeInputs } from 'ngxtension/inject-inputs';
|
|
7
7
|
import * as THREE from 'three';
|
|
8
8
|
import { Group, Mesh, PlaneGeometry, Scene, LineBasicMaterial, OrthographicCamera, MeshBasicMaterial, CubeCamera, RingGeometry, DirectionalLight, Vector2, RepeatWrapping, SpotLight, AmbientLight, PointLight } from 'three';
|
|
9
9
|
import { SimplexNoise, HorizontalBlurShader, VerticalBlurShader, RGBELoader, EXRLoader, GroundProjectedEnv, Sky, FullScreenQuad } from 'three-stdlib';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { helper, NgtsEdges, NgtsHelper } from 'angular-three-soba/abstractions';
|
|
11
|
+
import { fbo, getVersion } from 'angular-three-soba/misc';
|
|
12
12
|
import { NgTemplateOutlet } from '@angular/common';
|
|
13
13
|
import { HDRJPGLoader, GainMapLoader } from '@monogrid/gainmap-js';
|
|
14
14
|
import { assertInjector } from 'ngxtension/assert-injector';
|
|
15
|
-
import { injectTexture } from 'angular-three-soba/loaders';
|
|
15
|
+
import { injectTexture, textureResource } from 'angular-three-soba/loaders';
|
|
16
16
|
|
|
17
17
|
const defaultOptions$e = {
|
|
18
18
|
temporal: false,
|
|
@@ -95,7 +95,7 @@ class NgtsAccumulativeShadows {
|
|
|
95
95
|
clearTimeout(timeout);
|
|
96
96
|
});
|
|
97
97
|
});
|
|
98
|
-
|
|
98
|
+
beforeRender(() => {
|
|
99
99
|
const [frames, temporal, invalidate, limit] = [
|
|
100
100
|
this.frames(),
|
|
101
101
|
!!this.temporal(),
|
|
@@ -281,7 +281,7 @@ class NgtsBBAnchor {
|
|
|
281
281
|
bbAnchorParent['parent'].add(this.bbAnchorRef().nativeElement);
|
|
282
282
|
}
|
|
283
283
|
});
|
|
284
|
-
|
|
284
|
+
beforeRender(() => {
|
|
285
285
|
const parent = this.parent();
|
|
286
286
|
if (parent) {
|
|
287
287
|
boundingBox.setFromObject(parent);
|
|
@@ -392,7 +392,7 @@ class NgtsBounds {
|
|
|
392
392
|
this.clip();
|
|
393
393
|
}
|
|
394
394
|
});
|
|
395
|
-
|
|
395
|
+
beforeRender(({ delta }) => {
|
|
396
396
|
// This [additional animation step START] is needed to guarantee that delta used in animation isn't absurdly high (2-3 seconds) which is actually possible if rendering happens on demand...
|
|
397
397
|
if (this.animationState === AnimationState.START) {
|
|
398
398
|
this.animationState = AnimationState.ACTIVE;
|
|
@@ -621,7 +621,7 @@ class NgtsCameraShake {
|
|
|
621
621
|
callback();
|
|
622
622
|
onCleanup(() => void defaultControls.removeEventListener('change', callback));
|
|
623
623
|
});
|
|
624
|
-
|
|
624
|
+
beforeRender(({ delta, clock }) => {
|
|
625
625
|
const [{ maxYaw, yawFrequency, maxPitch, pitchFrequency, maxRoll, rollFrequency, decay, decayRate }, camera,] = [this.options(), this.store.snapshot.camera];
|
|
626
626
|
const shake = Math.pow(this.intensity, 2);
|
|
627
627
|
const yaw = maxYaw * shake * this.yawNoise.noise(clock.elapsedTime * yawFrequency, 1);
|
|
@@ -699,16 +699,16 @@ class NgtsCaustics {
|
|
|
699
699
|
settings: NORMAL_OPTIONS,
|
|
700
700
|
}));
|
|
701
701
|
// Buffers for front and back faces
|
|
702
|
-
this.normalTarget =
|
|
703
|
-
this.normalTargetB =
|
|
702
|
+
this.normalTarget = fbo(this.normalTargetParams);
|
|
703
|
+
this.normalTargetB = fbo(this.normalTargetParams);
|
|
704
704
|
this.causticsTargetParams = computed(() => ({
|
|
705
705
|
width: this.resolution(),
|
|
706
706
|
height: this.resolution(),
|
|
707
707
|
settings: CAUSTIC_OPTIONS,
|
|
708
708
|
}));
|
|
709
|
-
this.causticsTarget =
|
|
710
|
-
this.causticsTargetB =
|
|
711
|
-
this.cameraHelper =
|
|
709
|
+
this.causticsTarget = fbo(this.causticsTargetParams);
|
|
710
|
+
this.causticsTargetB = fbo(this.causticsTargetParams);
|
|
711
|
+
this.cameraHelper = helper(() => (this.debug() ? this.cameraRef().nativeElement : null), () => THREE.CameraHelper);
|
|
712
712
|
extend({
|
|
713
713
|
CausticsProjectionMaterial,
|
|
714
714
|
Group,
|
|
@@ -756,7 +756,7 @@ class NgtsCaustics {
|
|
|
756
756
|
helper: this.cameraHelper(),
|
|
757
757
|
};
|
|
758
758
|
});
|
|
759
|
-
|
|
759
|
+
beforeRender(({ gl }) => update(gl));
|
|
760
760
|
}
|
|
761
761
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: NgtsCaustics, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
762
762
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.1", type: NgtsCaustics, isStandalone: true, selector: "ngts-caustics", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "groupRef", first: true, predicate: ["group"], descendants: true, isSignal: true }, { propertyName: "sceneRef", first: true, predicate: ["scene"], descendants: true, isSignal: true }, { propertyName: "cameraRef", first: true, predicate: ["camera"], descendants: true, isSignal: true }, { propertyName: "planeRef", first: true, predicate: ["plane"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
@@ -1018,7 +1018,7 @@ class NgtsContactShadows {
|
|
|
1018
1018
|
});
|
|
1019
1019
|
extend({ Group, Mesh, MeshBasicMaterial, OrthographicCamera });
|
|
1020
1020
|
let count = 0;
|
|
1021
|
-
|
|
1021
|
+
beforeRender(() => {
|
|
1022
1022
|
const shadowsCamera = this.shadowsCameraRef()?.nativeElement;
|
|
1023
1023
|
if (!shadowsCamera)
|
|
1024
1024
|
return;
|
|
@@ -1154,8 +1154,8 @@ const ENVIRONMENT_PRESETS = {
|
|
|
1154
1154
|
};
|
|
1155
1155
|
const CUBEMAP_ROOT = 'https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/';
|
|
1156
1156
|
const defaultFiles = ['/px.png', '/nx.png', '/py.png', '/ny.png', '/pz.png', '/nz.png'];
|
|
1157
|
-
function
|
|
1158
|
-
return assertInjector(
|
|
1157
|
+
function environmentResource(options = () => ({}), { injector } = {}) {
|
|
1158
|
+
return assertInjector(environmentResource, injector, () => {
|
|
1159
1159
|
const adjustedOptions = computed(() => {
|
|
1160
1160
|
const { preset, extensions, colorSpace, ...rest } = options();
|
|
1161
1161
|
let { files, path } = rest;
|
|
@@ -1185,10 +1185,10 @@ function injectEnvironment(options = () => ({}), { injector } = {}) {
|
|
|
1185
1185
|
return;
|
|
1186
1186
|
store.gl().domElement.addEventListener('webglcontextlost', () => {
|
|
1187
1187
|
// @ts-expect-error - files is correctly passed
|
|
1188
|
-
|
|
1188
|
+
loaderResource.clear(multiFile ? [_files] : _files);
|
|
1189
1189
|
}, { once: true });
|
|
1190
1190
|
});
|
|
1191
|
-
const
|
|
1191
|
+
const resource = loaderResource(loader,
|
|
1192
1192
|
// @ts-expect-error - ensure the files is an array
|
|
1193
1193
|
() => {
|
|
1194
1194
|
const { files } = adjustedOptions();
|
|
@@ -1207,7 +1207,7 @@ function injectEnvironment(options = () => ({}), { injector } = {}) {
|
|
|
1207
1207
|
},
|
|
1208
1208
|
});
|
|
1209
1209
|
effect(() => {
|
|
1210
|
-
const loaderResult =
|
|
1210
|
+
const loaderResult = resource.value();
|
|
1211
1211
|
if (!loaderResult)
|
|
1212
1212
|
return;
|
|
1213
1213
|
const { extension, isCubeMap } = untracked(resultOptions);
|
|
@@ -1230,13 +1230,12 @@ function injectEnvironment(options = () => ({}), { injector } = {}) {
|
|
|
1230
1230
|
textureResult.colorSpace = colorSpace ?? (isCubeMap ? 'srgb' : 'srgb-linear');
|
|
1231
1231
|
texture.set(textureResult);
|
|
1232
1232
|
});
|
|
1233
|
-
return texture.asReadonly();
|
|
1233
|
+
return { texture: texture.asReadonly(), resource };
|
|
1234
1234
|
});
|
|
1235
1235
|
}
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
const { preset, extensions } = _options;
|
|
1236
|
+
environmentResource.preload = (options = {}) => {
|
|
1237
|
+
let { files, path } = options;
|
|
1238
|
+
const { preset, extensions } = options;
|
|
1240
1239
|
if (files == null) {
|
|
1241
1240
|
files = defaultFiles;
|
|
1242
1241
|
}
|
|
@@ -1255,15 +1254,15 @@ injectEnvironment.preload = (options = () => ({})) => {
|
|
|
1255
1254
|
const loader = getLoader(extension);
|
|
1256
1255
|
if (!loader)
|
|
1257
1256
|
throw new Error('injectEnvironment: Unrecognized file extension: ' + files);
|
|
1258
|
-
|
|
1257
|
+
loaderResource.preload(loader,
|
|
1259
1258
|
// @ts-expect-error - files is correctly passed
|
|
1260
|
-
|
|
1259
|
+
Array.isArray(files) ? [files] : files, (loader) => {
|
|
1261
1260
|
loader.setPath?.(path);
|
|
1262
1261
|
if (extensions)
|
|
1263
1262
|
extensions(loader);
|
|
1264
1263
|
});
|
|
1265
1264
|
};
|
|
1266
|
-
|
|
1265
|
+
environmentResource.clear = (clearOptions) => {
|
|
1267
1266
|
const options = { files: defaultFiles, ...clearOptions };
|
|
1268
1267
|
let { files } = options;
|
|
1269
1268
|
const preset = options.preset;
|
|
@@ -1271,7 +1270,7 @@ injectEnvironment.clear = (clearOptions) => {
|
|
|
1271
1270
|
validatePreset(preset);
|
|
1272
1271
|
files = ENVIRONMENT_PRESETS[preset];
|
|
1273
1272
|
}
|
|
1274
|
-
|
|
1273
|
+
loaderResource.clear(files);
|
|
1275
1274
|
};
|
|
1276
1275
|
function validatePreset(preset) {
|
|
1277
1276
|
if (!(preset in ENVIRONMENT_PRESETS))
|
|
@@ -1402,7 +1401,7 @@ class NgtsEnvironmentCube {
|
|
|
1402
1401
|
environmentRotation,
|
|
1403
1402
|
};
|
|
1404
1403
|
});
|
|
1405
|
-
const _texture =
|
|
1404
|
+
const { texture: _texture } = environmentResource(this.options);
|
|
1406
1405
|
effect((onCleanup) => {
|
|
1407
1406
|
const texture = _texture();
|
|
1408
1407
|
if (!texture)
|
|
@@ -1471,7 +1470,7 @@ class NgtsEnvironmentPortal {
|
|
|
1471
1470
|
onCleanup(() => cleanup?.());
|
|
1472
1471
|
});
|
|
1473
1472
|
let count = 1;
|
|
1474
|
-
|
|
1473
|
+
beforeRender(() => {
|
|
1475
1474
|
const frames = this.options().frames;
|
|
1476
1475
|
if (frames === Infinity || (frames != null && count < frames)) {
|
|
1477
1476
|
const camera = this.cameraRef()?.nativeElement;
|
|
@@ -1566,11 +1565,11 @@ class NgtsEnvironmentGround {
|
|
|
1566
1565
|
constructor() {
|
|
1567
1566
|
this.options = input({});
|
|
1568
1567
|
this.envSet = output();
|
|
1569
|
-
this.
|
|
1568
|
+
this.defaultEnvironment = environmentResource(this.options);
|
|
1570
1569
|
this.height = computed(() => this.options().ground?.height);
|
|
1571
1570
|
this.radius = computed(() => this.options().ground?.radius);
|
|
1572
1571
|
this.scale = computed(() => this.options().ground?.scale ?? 1000);
|
|
1573
|
-
this.args = computed(() => [this.options().map || this.
|
|
1572
|
+
this.args = computed(() => [this.options().map || this.defaultEnvironment.texture()]);
|
|
1574
1573
|
this.envMapOptions = computed(() => {
|
|
1575
1574
|
const { map: _, ...options } = this.options();
|
|
1576
1575
|
const [map] = this.args();
|
|
@@ -1578,7 +1577,7 @@ class NgtsEnvironmentGround {
|
|
|
1578
1577
|
});
|
|
1579
1578
|
extend({ GroundProjectedEnv });
|
|
1580
1579
|
inject(DestroyRef).onDestroy(() => {
|
|
1581
|
-
this.
|
|
1580
|
+
this.defaultEnvironment.texture()?.dispose();
|
|
1582
1581
|
});
|
|
1583
1582
|
}
|
|
1584
1583
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: NgtsEnvironmentGround, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
@@ -1646,6 +1645,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImpor
|
|
|
1646
1645
|
}]
|
|
1647
1646
|
}] });
|
|
1648
1647
|
|
|
1648
|
+
/**
|
|
1649
|
+
* @deprecated use environmentResource instead. Will be removed in v5.0.0
|
|
1650
|
+
* @since v4.0.0
|
|
1651
|
+
*/
|
|
1652
|
+
function injectEnvironment(options = () => ({}), { injector } = {}) {
|
|
1653
|
+
return assertInjector(injectEnvironment, injector, () => {
|
|
1654
|
+
const resource = environmentResource(options, { injector });
|
|
1655
|
+
return resource.texture;
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
injectEnvironment.preload = (options = () => ({})) => {
|
|
1659
|
+
environmentResource.preload(options());
|
|
1660
|
+
};
|
|
1661
|
+
injectEnvironment.clear = (clearOptions) => {
|
|
1662
|
+
environmentResource.clear(clearOptions);
|
|
1663
|
+
};
|
|
1664
|
+
|
|
1649
1665
|
const defaultOptions$7 = {
|
|
1650
1666
|
enabled: true,
|
|
1651
1667
|
speed: 1,
|
|
@@ -1668,7 +1684,7 @@ class NgtsFloat {
|
|
|
1668
1684
|
this.floatRef = viewChild.required('float');
|
|
1669
1685
|
extend({ Group });
|
|
1670
1686
|
const offset = Math.random() * 10000;
|
|
1671
|
-
|
|
1687
|
+
beforeRender(({ clock, invalidate }) => {
|
|
1672
1688
|
const [{ enabled, speed, rotationIntensity, floatingRange, floatIntensity, autoInvalidate }] = [
|
|
1673
1689
|
this.options(),
|
|
1674
1690
|
];
|
|
@@ -1890,6 +1906,10 @@ function getFormatString(format) {
|
|
|
1890
1906
|
}
|
|
1891
1907
|
const LIST_URL$1 = 'https://cdn.jsdelivr.net/gh/pmndrs/drei-assets@master/matcaps.json';
|
|
1892
1908
|
const MATCAP_ROOT = 'https://rawcdn.githack.com/emmelleppi/matcaps/9b36ccaaf0a24881a39062d05566c9e92be4aa0d';
|
|
1909
|
+
/**
|
|
1910
|
+
* @deprecated Use matcapTexture instead. Will be removed in v5.0.0
|
|
1911
|
+
* @since v4.0.0
|
|
1912
|
+
*/
|
|
1893
1913
|
function injectMatcapTexture(id = () => 0, { format = () => 1024, onLoad, injector, } = {}) {
|
|
1894
1914
|
return assertInjector(injectMatcapTexture, injector, () => {
|
|
1895
1915
|
const matcapList = signal({});
|
|
@@ -1916,20 +1936,46 @@ function injectMatcapTexture(id = () => 0, { format = () => 1024, onLoad, inject
|
|
|
1916
1936
|
return { url, texture: matcapTexture, numTot };
|
|
1917
1937
|
});
|
|
1918
1938
|
}
|
|
1939
|
+
function matcapTextureResource(id = () => 0, { format = () => 1024, onLoad, injector, } = {}) {
|
|
1940
|
+
return assertInjector(matcapTextureResource, injector, () => {
|
|
1941
|
+
const matcapList = signal({});
|
|
1942
|
+
fetch(LIST_URL$1)
|
|
1943
|
+
.then((res) => res.json())
|
|
1944
|
+
.then((list) => {
|
|
1945
|
+
matcapList.set(list);
|
|
1946
|
+
});
|
|
1947
|
+
const DEFAULT_MATCAP = computed(() => matcapList()[0]);
|
|
1948
|
+
const numTot = computed(() => Object.keys(matcapList()).length);
|
|
1949
|
+
const fileHash = computed(() => {
|
|
1950
|
+
const idValue = id();
|
|
1951
|
+
if (typeof idValue === 'string') {
|
|
1952
|
+
return idValue;
|
|
1953
|
+
}
|
|
1954
|
+
if (typeof idValue === 'number') {
|
|
1955
|
+
return matcapList()[idValue];
|
|
1956
|
+
}
|
|
1957
|
+
return null;
|
|
1958
|
+
});
|
|
1959
|
+
const fileName = computed(() => `${fileHash() || DEFAULT_MATCAP()}${getFormatString(format())}.png`);
|
|
1960
|
+
const url = computed(() => `${MATCAP_ROOT}/${format()}/${fileName()}`);
|
|
1961
|
+
const resource = textureResource(url, { onLoad });
|
|
1962
|
+
return { url, resource, numTot };
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1919
1965
|
class NgtsMatcapTexture {
|
|
1920
1966
|
constructor() {
|
|
1921
1967
|
this.matcapTexture = input();
|
|
1922
|
-
this.matcapTextureLoaded =
|
|
1968
|
+
this.matcapTextureLoaded = input();
|
|
1923
1969
|
this.template = inject(TemplateRef);
|
|
1924
1970
|
this.vcr = inject(ViewContainerRef);
|
|
1925
1971
|
this.id = computed(() => this.matcapTexture()?.id ?? 0);
|
|
1926
1972
|
this.format = computed(() => this.matcapTexture()?.format ?? 1024);
|
|
1927
|
-
const {
|
|
1973
|
+
const { resource } = matcapTextureResource(this.id, {
|
|
1928
1974
|
format: this.format,
|
|
1929
|
-
onLoad: this.matcapTextureLoaded
|
|
1975
|
+
onLoad: this.matcapTextureLoaded(),
|
|
1930
1976
|
});
|
|
1931
1977
|
effect(() => {
|
|
1932
|
-
this.ref = this.vcr.createEmbeddedView(this.template, { $implicit:
|
|
1978
|
+
this.ref = this.vcr.createEmbeddedView(this.template, { $implicit: resource });
|
|
1933
1979
|
this.ref.detectChanges();
|
|
1934
1980
|
});
|
|
1935
1981
|
inject(DestroyRef).onDestroy(() => {
|
|
@@ -1940,7 +1986,7 @@ class NgtsMatcapTexture {
|
|
|
1940
1986
|
return true;
|
|
1941
1987
|
}
|
|
1942
1988
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: NgtsMatcapTexture, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1943
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.1", type: NgtsMatcapTexture, isStandalone: true, selector: "ng-template[matcapTexture]", inputs: { matcapTexture: { classPropertyName: "matcapTexture", publicName: "matcapTexture", isSignal: true, isRequired: false, transformFunction: null }
|
|
1989
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.1", type: NgtsMatcapTexture, isStandalone: true, selector: "ng-template[matcapTexture]", inputs: { matcapTexture: { classPropertyName: "matcapTexture", publicName: "matcapTexture", isSignal: true, isRequired: false, transformFunction: null }, matcapTextureLoaded: { classPropertyName: "matcapTextureLoaded", publicName: "matcapTextureLoaded", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
1944
1990
|
}
|
|
1945
1991
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: NgtsMatcapTexture, decorators: [{
|
|
1946
1992
|
type: Directive,
|
|
@@ -1949,6 +1995,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImpor
|
|
|
1949
1995
|
|
|
1950
1996
|
const NORMAL_ROOT = 'https://rawcdn.githack.com/pmndrs/drei-assets/7a3104997e1576f83472829815b00880d88b32fb';
|
|
1951
1997
|
const LIST_URL = 'https://cdn.jsdelivr.net/gh/pmndrs/drei-assets@master/normals/normals.json';
|
|
1998
|
+
/**
|
|
1999
|
+
* @deprecated Use normalTexture instead. Will be removed in v5.0.0
|
|
2000
|
+
* @since v4.0.0
|
|
2001
|
+
*/
|
|
1952
2002
|
function injectNormalTexture(id = () => 0, { settings = () => ({}), onLoad, injector, }) {
|
|
1953
2003
|
return assertInjector(injectNormalTexture, injector, () => {
|
|
1954
2004
|
const normalList = signal({});
|
|
@@ -1985,10 +2035,46 @@ function injectNormalTexture(id = () => 0, { settings = () => ({}), onLoad, inje
|
|
|
1985
2035
|
return { url, texture: normalTexture, numTot };
|
|
1986
2036
|
});
|
|
1987
2037
|
}
|
|
2038
|
+
function normalTextureResource(id = () => 0, { settings = () => ({}), onLoad, injector, }) {
|
|
2039
|
+
return assertInjector(normalTextureResource, injector, () => {
|
|
2040
|
+
const normalList = signal({});
|
|
2041
|
+
fetch(LIST_URL)
|
|
2042
|
+
.then((res) => res.json())
|
|
2043
|
+
.then((list) => {
|
|
2044
|
+
normalList.set(list);
|
|
2045
|
+
});
|
|
2046
|
+
const DEFAULT_NORMAL = computed(() => normalList()[0]);
|
|
2047
|
+
const numTot = computed(() => Object.keys(normalList()).length);
|
|
2048
|
+
const fileHash = computed(() => {
|
|
2049
|
+
const idValue = id();
|
|
2050
|
+
if (typeof idValue === 'string') {
|
|
2051
|
+
return idValue;
|
|
2052
|
+
}
|
|
2053
|
+
if (typeof idValue === 'number') {
|
|
2054
|
+
return normalList()[idValue];
|
|
2055
|
+
}
|
|
2056
|
+
return null;
|
|
2057
|
+
});
|
|
2058
|
+
const imageName = computed(() => fileHash() || DEFAULT_NORMAL());
|
|
2059
|
+
const url = computed(() => `${NORMAL_ROOT}/normals/${imageName()}`);
|
|
2060
|
+
const resource = textureResource(url, { onLoad });
|
|
2061
|
+
effect(() => {
|
|
2062
|
+
if (!resource.hasValue())
|
|
2063
|
+
return;
|
|
2064
|
+
const texture = resource.value();
|
|
2065
|
+
const { anisotropy = 1, repeat = [1, 1], offset = [0, 0] } = settings();
|
|
2066
|
+
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
|
|
2067
|
+
texture.repeat = new THREE.Vector2(repeat[0], repeat[1]);
|
|
2068
|
+
texture.offset = new THREE.Vector2(offset[0], offset[1]);
|
|
2069
|
+
texture.anisotropy = anisotropy;
|
|
2070
|
+
});
|
|
2071
|
+
return { url, resource, numTot };
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
1988
2074
|
class NgtsNormalTexture {
|
|
1989
2075
|
constructor() {
|
|
1990
2076
|
this.normalTexture = input();
|
|
1991
|
-
this.normalTextureLoaded =
|
|
2077
|
+
this.normalTextureLoaded = input();
|
|
1992
2078
|
this.template = inject(TemplateRef);
|
|
1993
2079
|
this.vcr = inject(ViewContainerRef);
|
|
1994
2080
|
this.id = computed(() => this.normalTexture()?.id ?? 0);
|
|
@@ -1996,12 +2082,12 @@ class NgtsNormalTexture {
|
|
|
1996
2082
|
const { id: _, ...settings } = this.normalTexture() || {};
|
|
1997
2083
|
return settings;
|
|
1998
2084
|
});
|
|
1999
|
-
const {
|
|
2085
|
+
const { resource } = normalTextureResource(this.id, {
|
|
2000
2086
|
settings: this.settings,
|
|
2001
|
-
onLoad: this.normalTextureLoaded
|
|
2087
|
+
onLoad: this.normalTextureLoaded(),
|
|
2002
2088
|
});
|
|
2003
2089
|
effect(() => {
|
|
2004
|
-
this.ref = this.vcr.createEmbeddedView(this.template, { $implicit:
|
|
2090
|
+
this.ref = this.vcr.createEmbeddedView(this.template, { $implicit: resource });
|
|
2005
2091
|
this.ref.detectChanges();
|
|
2006
2092
|
});
|
|
2007
2093
|
inject(DestroyRef).onDestroy(() => {
|
|
@@ -2012,7 +2098,7 @@ class NgtsNormalTexture {
|
|
|
2012
2098
|
return true;
|
|
2013
2099
|
}
|
|
2014
2100
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: NgtsNormalTexture, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2015
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.1", type: NgtsNormalTexture, isStandalone: true, selector: "ng-template[normalTexture]", inputs: { normalTexture: { classPropertyName: "normalTexture", publicName: "normalTexture", isSignal: true, isRequired: false, transformFunction: null }
|
|
2101
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.1", type: NgtsNormalTexture, isStandalone: true, selector: "ng-template[normalTexture]", inputs: { normalTexture: { classPropertyName: "normalTexture", publicName: "normalTexture", isSignal: true, isRequired: false, transformFunction: null }, normalTextureLoaded: { classPropertyName: "normalTextureLoaded", publicName: "normalTextureLoaded", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
2016
2102
|
}
|
|
2017
2103
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: NgtsNormalTexture, decorators: [{
|
|
2018
2104
|
type: Directive,
|
|
@@ -2222,7 +2308,7 @@ class NgtsRenderTextureImpl {
|
|
|
2222
2308
|
}));
|
|
2223
2309
|
this.renderPriority = pick(this.options, 'renderPriority');
|
|
2224
2310
|
this.frames = pick(this.options, 'frames');
|
|
2225
|
-
this.fbo =
|
|
2311
|
+
this.fbo = fbo(this.fboParams);
|
|
2226
2312
|
this.virtualScene = (() => {
|
|
2227
2313
|
const scene = new THREE.Scene();
|
|
2228
2314
|
scene.name = `ngts-render-texture-virtual-scene-${incrementId++}`;
|
|
@@ -2406,6 +2492,7 @@ const defaultVolumetricMeshOptions = {
|
|
|
2406
2492
|
attenuation: 5,
|
|
2407
2493
|
anglePower: 5,
|
|
2408
2494
|
color: 'white',
|
|
2495
|
+
depthBuffer: null,
|
|
2409
2496
|
};
|
|
2410
2497
|
class NgtsVolumetricMesh {
|
|
2411
2498
|
constructor() {
|
|
@@ -2435,7 +2522,7 @@ class NgtsVolumetricMesh {
|
|
|
2435
2522
|
});
|
|
2436
2523
|
extend({ Mesh });
|
|
2437
2524
|
const vec = new THREE.Vector3();
|
|
2438
|
-
|
|
2525
|
+
beforeRender(() => {
|
|
2439
2526
|
const mesh = this.meshRef().nativeElement;
|
|
2440
2527
|
const material = this.material;
|
|
2441
2528
|
material.uniforms['spotPosition'].value.copy(mesh.getWorldPosition(vec));
|
|
@@ -2487,8 +2574,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImpor
|
|
|
2487
2574
|
imports: [NgtArgs],
|
|
2488
2575
|
}]
|
|
2489
2576
|
}], ctorParameters: () => [] });
|
|
2490
|
-
function
|
|
2491
|
-
assertInjector(
|
|
2577
|
+
function spotLightCommon(spotLight, mesh, width, height, distance, injector) {
|
|
2578
|
+
assertInjector(spotLightCommon, injector, () => {
|
|
2492
2579
|
const pos = new THREE.Vector3();
|
|
2493
2580
|
const dir = new THREE.Vector3();
|
|
2494
2581
|
effect(() => {
|
|
@@ -2506,7 +2593,7 @@ function injectSpotLightCommon(spotLight, mesh, width, height, distance, injecto
|
|
|
2506
2593
|
throw new Error('NgtsSpotLightShadow must be a child of a NgtsSpotLight');
|
|
2507
2594
|
}
|
|
2508
2595
|
});
|
|
2509
|
-
|
|
2596
|
+
beforeRender(() => {
|
|
2510
2597
|
const [_spotLight, _mesh] = [spotLight()?.nativeElement, mesh()?.nativeElement];
|
|
2511
2598
|
if (!_spotLight || !_mesh)
|
|
2512
2599
|
return;
|
|
@@ -2573,7 +2660,7 @@ class NgtsSpotLightShadowShader {
|
|
|
2573
2660
|
uTime: { value: 0 },
|
|
2574
2661
|
};
|
|
2575
2662
|
extend({ Mesh, PlaneGeometry, MeshBasicMaterial });
|
|
2576
|
-
|
|
2663
|
+
spotLightCommon(this.spotLight.spotLightRef, this.meshRef, this.width, this.height, this.distance);
|
|
2577
2664
|
effect(() => {
|
|
2578
2665
|
this.uniforms.uShadowMap.value = this.map();
|
|
2579
2666
|
});
|
|
@@ -2590,7 +2677,7 @@ class NgtsSpotLightShadowShader {
|
|
|
2590
2677
|
renderTarget.dispose();
|
|
2591
2678
|
});
|
|
2592
2679
|
});
|
|
2593
|
-
|
|
2680
|
+
beforeRender(({ gl, delta }) => {
|
|
2594
2681
|
this.uniforms.uTime.value += delta;
|
|
2595
2682
|
gl.setRenderTarget(this.renderTarget());
|
|
2596
2683
|
this.fsQuad().render(gl);
|
|
@@ -2655,7 +2742,7 @@ class NgtsSpotLightShadowNoShader {
|
|
|
2655
2742
|
this.height = pick(this.options, 'height');
|
|
2656
2743
|
this.distance = pick(this.options, 'distance');
|
|
2657
2744
|
extend({ Mesh, PlaneGeometry, MeshBasicMaterial });
|
|
2658
|
-
|
|
2745
|
+
spotLightCommon(this.spotLight.spotLightRef, this.meshRef, this.width, this.height, this.distance);
|
|
2659
2746
|
}
|
|
2660
2747
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: NgtsSpotLightShadowNoShader, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2661
2748
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.1", type: NgtsSpotLightShadowNoShader, isStandalone: true, selector: "ngts-spot-light-shadow-no-shader", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "meshRef", first: true, predicate: ["mesh"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
@@ -2733,6 +2820,7 @@ const defaultOptions$1 = {
|
|
|
2733
2820
|
anglePower: 5,
|
|
2734
2821
|
volumetric: true,
|
|
2735
2822
|
debug: false,
|
|
2823
|
+
depthBuffer: null,
|
|
2736
2824
|
};
|
|
2737
2825
|
class NgtsSpotLight {
|
|
2738
2826
|
constructor() {
|
|
@@ -3051,5 +3139,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImpor
|
|
|
3051
3139
|
* Generated bundle index. Do not edit.
|
|
3052
3140
|
*/
|
|
3053
3141
|
|
|
3054
|
-
export { ENVIRONMENT_PRESETS, NgtsAccumulativeShadows, NgtsBBAnchor, NgtsBackdrop, NgtsBounds, NgtsCameraShake, NgtsCaustics, NgtsCenter, NgtsContactShadows, NgtsEnvironment, NgtsEnvironmentCube, NgtsEnvironmentGround, NgtsEnvironmentMap, NgtsEnvironmentPortal, NgtsFloat, NgtsLightformer, NgtsMask, NgtsMatcapTexture, NgtsNormalTexture, NgtsRandomizedLights, NgtsRenderTexture, NgtsRenderTextureContainer, NgtsRenderTextureContent, NgtsRenderTextureImpl, NgtsSky, NgtsSpotLight, NgtsSpotLightShadow, NgtsStage, NgtsStageRefit, calcPosFromAngles, injectEnvironment, injectMatcapTexture, injectNormalTexture, mask };
|
|
3142
|
+
export { ENVIRONMENT_PRESETS, NgtsAccumulativeShadows, NgtsBBAnchor, NgtsBackdrop, NgtsBounds, NgtsCameraShake, NgtsCaustics, NgtsCenter, NgtsContactShadows, NgtsEnvironment, NgtsEnvironmentCube, NgtsEnvironmentGround, NgtsEnvironmentMap, NgtsEnvironmentPortal, NgtsFloat, NgtsLightformer, NgtsMask, NgtsMatcapTexture, NgtsNormalTexture, NgtsRandomizedLights, NgtsRenderTexture, NgtsRenderTextureContainer, NgtsRenderTextureContent, NgtsRenderTextureImpl, NgtsSky, NgtsSpotLight, NgtsSpotLightShadow, NgtsStage, NgtsStageRefit, calcPosFromAngles, environmentResource, injectEnvironment, injectMatcapTexture, injectNormalTexture, mask, matcapTextureResource, normalTextureResource };
|
|
3055
3143
|
//# sourceMappingURL=angular-three-soba-staging.mjs.map
|