@3driseai/3drise-viewer 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CreatedObject.d.ts.map +1 -1
- package/dist/components/CreatedObject.js +18 -14
- package/dist/components/ModelMaterialPassContext.d.ts +7 -0
- package/dist/components/ModelMaterialPassContext.d.ts.map +1 -0
- package/dist/components/ModelMaterialPassContext.js +7 -0
- package/dist/components/ModelPrimitive.d.ts.map +1 -1
- package/dist/components/ModelPrimitive.js +7 -1
- package/dist/components/ParticlesGenerator.d.ts.map +1 -1
- package/dist/components/ParticlesGenerator.js +6 -0
- package/dist/components/particles/ChladniSandParticles.d.ts +15 -0
- package/dist/components/particles/ChladniSandParticles.d.ts.map +1 -0
- package/dist/components/particles/ChladniSandParticles.js +912 -0
- package/dist/components/particles/FaradayPowderParticles.d.ts +15 -0
- package/dist/components/particles/FaradayPowderParticles.d.ts.map +1 -0
- package/dist/components/particles/FaradayPowderParticles.js +783 -0
- package/dist/components/particles/NeonRainParticles.d.ts +15 -0
- package/dist/components/particles/NeonRainParticles.d.ts.map +1 -0
- package/dist/components/particles/NeonRainParticles.js +716 -0
- package/dist/components/particles/index.d.ts +6 -0
- package/dist/components/particles/index.d.ts.map +1 -1
- package/dist/components/particles/index.js +3 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useMaterialApplication.d.ts.map +1 -1
- package/dist/hooks/useMaterialApplication.js +1 -0
- package/dist/hooks/useNodeOverrides.d.ts +13 -0
- package/dist/hooks/useNodeOverrides.d.ts.map +1 -0
- package/dist/hooks/useNodeOverrides.js +254 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreatedObject.d.ts","sourceRoot":"","sources":["../../src/components/CreatedObject.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CreatedObject.d.ts","sourceRoot":"","sources":["../../src/components/CreatedObject.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAUnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,UAAU,kBAAmB,SAAQ,gBAAgB;IACjD,aAAa,EAAE,qBAAqB,CAAC;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CACpH;AAGD,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAmF9C,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useRef, useEffect, useState, memo } from "react";
|
|
2
|
+
import { useRef, useEffect, useState, useReducer, memo } from "react";
|
|
3
|
+
import { ModelMaterialPassContext } from "./ModelMaterialPassContext.js";
|
|
3
4
|
import { DEFAULT_EDGES_SETTINGS } from "@3driseai/3drise-core";
|
|
4
5
|
import { useMaterialApplication } from "../hooks/useMaterialApplication.js";
|
|
5
6
|
import { useShadowApplication } from "../hooks/useShadowApplication.js";
|
|
@@ -29,7 +30,10 @@ const CreatedObject = memo(({ createdObject, children, shouldApply3driseMaterial
|
|
|
29
30
|
const [mountedObject, setMountedObject] = useState(null);
|
|
30
31
|
useObjectEdges(createdObject.id, createdObject.edgesSettings ?? DEFAULT_EDGES_SETTINGS, meshRef);
|
|
31
32
|
// useObjectGenerativeEffects(mountedObject, createdObject.effects);
|
|
32
|
-
|
|
33
|
+
// Bumped when the model-level material pass lands, so per-mesh overrides
|
|
34
|
+
// (useNodeOverrides in ModelPrimitive) re-apply on top of it.
|
|
35
|
+
const [materialPass, bumpMaterialPass] = useReducer((n) => n + 1, 0);
|
|
36
|
+
useMaterialApplication(meshRef, createdObject.materialSettings, shouldApply3driseMaterial, bumpMaterialPass);
|
|
33
37
|
useShadowApplication(meshRef, createdObject.meshSettings.castShadow, createdObject.meshSettings.receiveShadow);
|
|
34
38
|
const anchoredPosition = cameraManager.getAnchorPosition(createdObject.meshSettings.anchor?.anchor || 'center', 0, createdObject.meshSettings.anchor?.offset || { y: 0, x: 0, z: 0 }, createdObject.meshSettings.anchor?.padding || 0);
|
|
35
39
|
useEffect(() => {
|
|
@@ -77,19 +81,19 @@ const CreatedObject = memo(({ createdObject, children, shouldApply3driseMaterial
|
|
|
77
81
|
e.stopPropagation();
|
|
78
82
|
};
|
|
79
83
|
const anchorEnabled = createdObject.meshSettings.anchor && createdObject.meshSettings.anchor.enabled;
|
|
80
|
-
return (_jsx(AnimatedObject
|
|
81
|
-
// animationId={createdObject.animationId || ''}
|
|
82
|
-
, {
|
|
84
|
+
return (_jsx(ModelMaterialPassContext.Provider, { value: materialPass, children: _jsx(AnimatedObject
|
|
83
85
|
// animationId={createdObject.animationId || ''}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
, {
|
|
87
|
+
// animationId={createdObject.animationId || ''}
|
|
88
|
+
stateKey: createdObject.id, transitionSettings: {
|
|
89
|
+
...animatedTransform,
|
|
90
|
+
position: anchorEnabled ? [anchoredPosition.x, anchoredPosition.y, anchoredPosition.z] : animatedTransform.position
|
|
91
|
+
}, createdObject: createdObject,
|
|
92
|
+
// animateMaterial={!useDreiMaterials}
|
|
93
|
+
parentRef: meshRef, onObjectReady: onObjectReady, onObjectDispose: onObjectDispose, visible: createdObject.meshSettings.visible, handleObjectClick: handleObjectClick, onPointerEnter: handleObjectEnter, onPointerLeave: e => handleObjectLeave(e), hovered: hovered, children: createdObject.rigidBodySettings?.enabled ? (_jsx(RigidBody, { type: createdObject.rigidBodySettings?.type || 'dynamic', mass: createdObject.rigidBodySettings?.mass || 1, colliders: createdObject.userData?.type === 'plane'
|
|
94
|
+
? 'cuboid' // Force box collider for planes
|
|
95
|
+
: undefined // Auto-detect for others
|
|
96
|
+
, friction: createdObject.rigidBodySettings?.friction, restitution: createdObject.rigidBodySettings?.restitution, gravityScale: createdObject.rigidBodySettings?.gravityScale ?? 1, linearDamping: createdObject.rigidBodySettings?.linearDamping ?? 0.01, angularDamping: createdObject.rigidBodySettings?.angularDamping ?? 0.01, children: children })) : (children) }) }));
|
|
93
97
|
});
|
|
94
98
|
CreatedObject.displayName = 'CreatedObject';
|
|
95
99
|
export default CreatedObject;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bumped by CreatedObject every time its model-level material pass
|
|
3
|
+
* (useMaterialApplication) finishes. Per-mesh overrides re-apply on top of it, because
|
|
4
|
+
* the pass replaces every material in the model — including the ones an override set.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ModelMaterialPassContext: import("react").Context<number>;
|
|
7
|
+
//# sourceMappingURL=ModelMaterialPassContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelMaterialPassContext.d.ts","sourceRoot":"","sources":["../../src/components/ModelMaterialPassContext.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,iCAAmB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Bumped by CreatedObject every time its model-level material pass
|
|
4
|
+
* (useMaterialApplication) finishes. Per-mesh overrides re-apply on top of it, because
|
|
5
|
+
* the pass replaces every material in the model — including the ones an override set.
|
|
6
|
+
*/
|
|
7
|
+
export const ModelMaterialPassContext = createContext(0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelPrimitive.d.ts","sourceRoot":"","sources":["../../src/components/ModelPrimitive.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ModelPrimitive.d.ts","sourceRoot":"","sources":["../../src/components/ModelPrimitive.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAKnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,UAAU,mBAAoB,SAAQ,gBAAgB;IAClD,aAAa,EAAE,qBAAqB,CAAC;IACrC,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAkChD,CAAC;AAIH,eAAe,cAAc,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useCallback, useRef } from 'react';
|
|
2
|
+
import { memo, useCallback, useMemo, useRef } from 'react';
|
|
3
3
|
import { useModelObject } from '../hooks/useModelObject.js';
|
|
4
|
+
import { useNodeOverrides } from '../hooks/useNodeOverrides.js';
|
|
5
|
+
import { getNodeOverrides, peekModelAsset } from '@3driseai/3drise-core';
|
|
4
6
|
import { useObjectReadyReporter } from '../hooks/useObjectReady.js';
|
|
5
7
|
/**
|
|
6
8
|
* Mounts the Object3D behind a `type: 'model'` scene object, and hands it to the host
|
|
@@ -32,6 +34,10 @@ import { useObjectReadyReporter } from '../hooks/useObjectReady.js';
|
|
|
32
34
|
const ModelPrimitive = memo(({ createdObject, slot = 0, onObjectReady, onObjectDispose, children }) => {
|
|
33
35
|
const attachedRef = useRef(null);
|
|
34
36
|
const object = useModelObject(createdObject, slot);
|
|
37
|
+
// Per-mesh overrides (ModelTree). Originals come from the never-mounted cache master.
|
|
38
|
+
const url = createdObject.userData?.url;
|
|
39
|
+
const master = useMemo(() => (url ? peekModelAsset(url)?.scene ?? null : null), [url, object]);
|
|
40
|
+
useNodeOverrides(object, getNodeOverrides(createdObject), master);
|
|
35
41
|
const { report, reportDisposed } = useObjectReadyReporter(createdObject, onObjectReady, onObjectDispose);
|
|
36
42
|
const setObjectRef = useCallback((instance) => {
|
|
37
43
|
if (instance) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParticlesGenerator.d.ts","sourceRoot":"","sources":["../../src/components/ParticlesGenerator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ParticlesGenerator.d.ts","sourceRoot":"","sources":["../../src/components/ParticlesGenerator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAU7D,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;IAC7D,QAAQ,EAAE,2BAA2B,CAAC;CACzC;AAED,0FAA0F;AAC1F,QAAA,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAgBzD,CAAC;AACF,eAAe,kBAAkB,CAAC"}
|
|
@@ -4,6 +4,9 @@ import BrownianDustParticles from './particles/BrownianDustParticles.js';
|
|
|
4
4
|
import BioluminescentWakeParticles from './particles/BioluminescentWakeParticles.js';
|
|
5
5
|
import ElectronOrbitalsParticles from './particles/ElectronOrbitalsParticles.js';
|
|
6
6
|
import GrinderSparksParticles from './particles/GrinderSparksParticles.js';
|
|
7
|
+
import ChladniSandParticles from './particles/ChladniSandParticles.js';
|
|
8
|
+
import FaradayPowderParticles from './particles/FaradayPowderParticles.js';
|
|
9
|
+
import NeonRainParticles from './particles/NeonRainParticles.js';
|
|
7
10
|
/** Standalone generative particle objects (type 'particles'), switched on config.type. */
|
|
8
11
|
const ParticlesGenerator = ({ settings, onObjectReady, onObjectDispose }) => {
|
|
9
12
|
const { config, animations } = settings;
|
|
@@ -17,6 +20,9 @@ const ParticlesGenerator = ({ settings, onObjectReady, onObjectDispose }) => {
|
|
|
17
20
|
case 'bioluminescentWake': return _jsx(BioluminescentWakeParticles, { id: settings.id, size: size, config: config, animations: animations, ...ready });
|
|
18
21
|
case 'electronOrbitals': return _jsx(ElectronOrbitalsParticles, { id: settings.id, size: size, config: config, animations: animations, ...ready });
|
|
19
22
|
case 'grinderSparks': return _jsx(GrinderSparksParticles, { id: settings.id, size: size, config: config, animations: animations, ...ready });
|
|
23
|
+
case 'chladniSand': return _jsx(ChladniSandParticles, { id: settings.id, size: size, config: config, animations: animations, ...ready });
|
|
24
|
+
case 'faradayPowder': return _jsx(FaradayPowderParticles, { id: settings.id, size: size, config: config, animations: animations, ...ready });
|
|
25
|
+
case 'neonRain': return _jsx(NeonRainParticles, { id: settings.id, size: size, config: config, animations: animations, ...ready });
|
|
20
26
|
default: return null;
|
|
21
27
|
}
|
|
22
28
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ObjectAnimations, ChladniSandParticlesConfig } from '@3driseai/3drise-core';
|
|
3
|
+
import type { ObjectReadyProps } from '../../types/objectReady';
|
|
4
|
+
export interface ChladniSandParticlesProps extends ObjectReadyProps {
|
|
5
|
+
/** Scene object id: the controller finds the live-edit handle by it. */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** World size of the object (units); the object's transform scales it further. */
|
|
8
|
+
size: number;
|
|
9
|
+
config: ChladniSandParticlesConfig;
|
|
10
|
+
/** Per-domain keyframes; the `particles` domain drives this object's config knobs. */
|
|
11
|
+
animations?: ObjectAnimations;
|
|
12
|
+
}
|
|
13
|
+
declare const ChladniSandParticles: React.FC<ChladniSandParticlesProps>;
|
|
14
|
+
export default ChladniSandParticles;
|
|
15
|
+
//# sourceMappingURL=ChladniSandParticles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChladniSandParticles.d.ts","sourceRoot":"","sources":["../../../src/components/particles/ChladniSandParticles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmE,MAAM,OAAO,CAAC;AAIxF,OAAO,KAAK,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAM1F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IAC/D,wEAAwE;IACxE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,0BAA0B,CAAC;IACnC,sFAAsF;IACtF,UAAU,CAAC,EAAE,gBAAgB,CAAC;CACjC;AAsvBD,QAAA,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAiD7D,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|