@ntalmagor/3drize-viewer 0.1.12 → 0.1.14
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.
|
@@ -1,33 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import type { AnimationSequence, CameraState, CreatedObjectSettings, DeviceType, FogSettings, GeneralObjectSettings, GridConfig, HdrSettings, OceanSettings, PhysicsSettings, RainSettings, SkySettings, StarsSettings, TimeSettings } from "@ntalmagor/3drize-core";
|
|
4
|
-
import { type ThreeEvent } from '@react-three/fiber';
|
|
5
|
-
type ProductionSceneProps = {
|
|
6
|
-
device: DeviceType;
|
|
7
|
-
onObjectsReady?: () => void;
|
|
8
|
-
gridSettings: GridConfig;
|
|
9
|
-
hdr: HdrSettings;
|
|
10
|
-
physicsSettings: PhysicsSettings;
|
|
11
|
-
generalObjectSettings: GeneralObjectSettings;
|
|
12
|
-
ocean: OceanSettings;
|
|
13
|
-
cameraSettings: CameraState;
|
|
14
|
-
selectedLight: any;
|
|
15
|
-
objects: CreatedObjectSettings[];
|
|
16
|
-
lighting: any;
|
|
17
|
-
controls: any;
|
|
18
|
-
geometry: any;
|
|
19
|
-
structure: any;
|
|
20
|
-
isPathMode: boolean;
|
|
21
|
-
editingPath: any;
|
|
22
|
-
sky: SkySettings;
|
|
23
|
-
timeSettings: TimeSettings;
|
|
24
|
-
starsSettings: StarsSettings;
|
|
25
|
-
clouds: any;
|
|
26
|
-
rainSettings: RainSettings;
|
|
27
|
-
fogSettings: FogSettings;
|
|
28
|
-
animationSequences: AnimationSequence[];
|
|
29
|
-
onObjectClick?: (object: CreatedObjectSettings, ref: Object3D, event: ThreeEvent<MouseEvent>) => void;
|
|
30
|
-
};
|
|
2
|
+
import type { ProductionSceneProps } from "@ntalmagor/3drize-core";
|
|
31
3
|
declare const ProductionScene: React.FC<ProductionSceneProps>;
|
|
32
4
|
export default ProductionScene;
|
|
33
5
|
//# sourceMappingURL=ProductionScene.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductionScene.d.ts","sourceRoot":"","sources":["../../src/components/ProductionScene.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ProductionScene.d.ts","sourceRoot":"","sources":["../../src/components/ProductionScene.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,KAAK,EAAsC,oBAAoB,EAAG,MAAM,wBAAwB,CAAC;AAUxG,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAkCnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -2,38 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { OrbitControls } from "@react-three/drei";
|
|
3
3
|
import { Physics } from "@react-three/rapier";
|
|
4
4
|
import { Vector3 } from "three";
|
|
5
|
-
|
|
6
|
-
// import { ShaderMesh } from "~/components/MaterialCreator/components";
|
|
7
|
-
// import StructureRenderer from "~/components/StructureRenderer/StructureRenderer";
|
|
8
|
-
import PathRenderer from "./PathRenderer.js";
|
|
9
|
-
import LightsManager from "./LightsManager.js";
|
|
10
|
-
import EnvironmentManager from "./EnvironmentManager.js";
|
|
11
|
-
import CameraController from "./CameraController.js";
|
|
12
|
-
import Ocean from "./Ocean.js";
|
|
13
|
-
import ObjectsRenderer from "./ObjectsRenderer.js";
|
|
14
|
-
import { useInteraction } from "../hooks/useInteraction.js";
|
|
15
|
-
const ProductionScene = ({ onObjectsReady, onObjectClick, gridSettings, hdr, physicsSettings, generalObjectSettings, ocean, cameraSettings, selectedLight, objects, lighting, controls, geometry, structure, isPathMode, editingPath, sky, timeSettings, starsSettings, clouds, rainSettings, fogSettings, animationSequences, }) => {
|
|
16
|
-
const sunSystem = sky.sunSystem;
|
|
17
|
-
const mode = 'default';
|
|
18
|
-
// console.log({animationSequences})
|
|
5
|
+
const ProductionScene = ({ physicsSettings, controls, children, }) => {
|
|
19
6
|
// Interaction hook
|
|
20
|
-
|
|
21
|
-
cameraSettings,
|
|
22
|
-
sequences: animationSequences,
|
|
23
|
-
});
|
|
24
|
-
function filterInteractionsByEvent(interactions, mouseEvent) {
|
|
25
|
-
if (!interactions)
|
|
26
|
-
return [];
|
|
27
|
-
return interactions.filter((interaction) => interaction.mouseEvent === mouseEvent);
|
|
28
|
-
}
|
|
29
|
-
const handleObjectClick = (createdObject, ref, event) => {
|
|
30
|
-
console.log('[ProductionScene] handleObjectClick:', createdObject.id);
|
|
31
|
-
const clickInteractions = filterInteractionsByEvent(createdObject.interactions?.actions, 'click');
|
|
32
|
-
clickInteractions.forEach((interaction) => {
|
|
33
|
-
executeInteraction({ interaction, ref, createdObject });
|
|
34
|
-
});
|
|
35
|
-
onObjectClick && onObjectClick(createdObject, ref, event);
|
|
36
|
-
};
|
|
37
|
-
return (_jsxs(Physics, { gravity: physicsSettings.gravity, paused: !physicsSettings.enabled, debug: physicsSettings.debug, children: [_jsx(LightsManager, { lights: lighting, selectedLight: selectedLight }), _jsx(EnvironmentManager, { hdrSettings: hdr, timeSettings: timeSettings, visible: true, sunSystemVisible: sunSystem.visible, sunSize: sunSystem.sunSize, moonSize: sunSystem.moonSize, sunIntensity: sunSystem.intensity, castShadow: sunSystem.castShadow, shadowMapSize: sunSystem.shadowMapSize, starsSettings: starsSettings, skyControllerSettings: sky.visible && !sunSystem.visible ? sky : undefined, cloudsSettings: clouds, cloudsMaterialSettings: clouds.materialSettings, rainSettings: rainSettings, fogSettings: fogSettings }), _jsx(CameraController, { settings: cameraSettings }), _jsx(Ocean, { settings: ocean }), _jsx(ObjectsRenderer, { cameraSettings: cameraSettings, generalObjectSettings: generalObjectSettings, createdObjects: objects, onObjectsReady: onObjectsReady, handleObjectClick: handleObjectClick }), isPathMode && editingPath && _jsx(PathRenderer, { pathSettings: editingPath }), _jsx(OrbitControls, { makeDefault: true, enabled: controls.enabled, target: new Vector3(...controls.target), enablePan: controls.enablePan, enableRotate: controls.enableRotate, autoRotate: controls.autoRotate, autoRotateSpeed: controls.autoRotateSpeed, zoomSpeed: controls.zoomSpeed, panSpeed: controls.panSpeed, rotateSpeed: controls.rotateSpeed, minDistance: controls.minDistance, maxDistance: controls.maxDistance, minPolarAngle: controls.minPolarAngle ? controls.minPolarAngle : -Infinity, maxPolarAngle: controls.maxPolarAngle ? controls.maxPolarAngle : Infinity, minAzimuthAngle: controls.minAzimuthAngle ? controls.minAzimuthAngle : -Infinity, maxAzimuthAngle: controls.maxAzimuthAngle ? controls.maxAzimuthAngle : Infinity })] }));
|
|
7
|
+
return (_jsxs(Physics, { gravity: physicsSettings.gravity, paused: !physicsSettings.enabled, debug: physicsSettings.debug, children: [children, _jsx(OrbitControls, { makeDefault: true, enabled: controls.enabled, target: new Vector3(...controls.target), enablePan: controls.enablePan, enableRotate: controls.enableRotate, autoRotate: controls.autoRotate, autoRotateSpeed: controls.autoRotateSpeed, zoomSpeed: controls.zoomSpeed, panSpeed: controls.panSpeed, rotateSpeed: controls.rotateSpeed, minDistance: controls.minDistance, maxDistance: controls.maxDistance, minPolarAngle: controls.minPolarAngle ? controls.minPolarAngle : -Infinity, maxPolarAngle: controls.maxPolarAngle ? controls.maxPolarAngle : Infinity, minAzimuthAngle: controls.minAzimuthAngle ? controls.minAzimuthAngle : -Infinity, maxAzimuthAngle: controls.maxAzimuthAngle ? controls.maxAzimuthAngle : Infinity })] }));
|
|
38
8
|
};
|
|
39
9
|
export default ProductionScene;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneBuilder.d.ts","sourceRoot":"","sources":["../../src/components/SceneBuilder.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SceneBuilder.d.ts","sourceRoot":"","sources":["../../src/components/SceneBuilder.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,OAAO,KAAK,EAEV,iBAAiB,EAIlB,MAAM,wBAAwB,CAAC;AAWhC,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAoM7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { Canvas } from "@react-three/fiber";
|
|
4
|
-
// import type { SceneBuilderProps } from "~/types/types";
|
|
5
4
|
import useMeshController from "../hooks/useMeshController.js";
|
|
6
5
|
import { loadAssets } from "@ntalmagor/3drize-core";
|
|
7
6
|
import { NoToneMapping } from "three";
|
|
8
7
|
import ProductionScene from "./ProductionScene.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import LightsManager from "./LightsManager.js";
|
|
9
|
+
import EnvironmentManager from "./EnvironmentManager.js";
|
|
10
|
+
import CameraController from "./CameraController.js";
|
|
11
|
+
import Ocean from "./Ocean.js";
|
|
12
|
+
import ObjectsRenderer from "./ObjectsRenderer.js";
|
|
13
|
+
import { useInteraction } from "../hooks/useInteraction.js";
|
|
14
|
+
const SceneBuilder = ({ project, width = "100%", height = "100vh", style = {}, className = "", onSceneInitialized, onUiElementClick, onObjectClick, }) => {
|
|
12
15
|
const sceneSettings = (project.sceneSettingsData || {});
|
|
13
16
|
const meshController = useMeshController();
|
|
14
17
|
const [isThreeJsMounted, setIsThreeJsMounted] = useState(false);
|
|
@@ -45,13 +48,13 @@ const SceneBuilder = ({ project, width = "100%", height = "100vh", style = {}, c
|
|
|
45
48
|
minAzimuthAngle: -Infinity,
|
|
46
49
|
maxAzimuthAngle: Infinity,
|
|
47
50
|
};
|
|
48
|
-
const { shadows, antialias, dpr, gl, backgroundColor
|
|
49
|
-
const { position, orientation, fov, near, far
|
|
51
|
+
const { shadows, antialias, dpr, gl, backgroundColor } = sceneCanvas;
|
|
52
|
+
const { position, orientation, fov, near, far } = camera;
|
|
50
53
|
const containerStyle = {
|
|
51
54
|
width,
|
|
52
55
|
height,
|
|
53
|
-
position:
|
|
54
|
-
overflow:
|
|
56
|
+
position: "relative",
|
|
57
|
+
overflow: "hidden",
|
|
55
58
|
...style,
|
|
56
59
|
};
|
|
57
60
|
useEffect(() => {
|
|
@@ -81,12 +84,30 @@ const SceneBuilder = ({ project, width = "100%", height = "100vh", style = {}, c
|
|
|
81
84
|
onUiElementClick(element);
|
|
82
85
|
}
|
|
83
86
|
};
|
|
87
|
+
function filterInteractionsByEvent(interactions, mouseEvent) {
|
|
88
|
+
if (!interactions)
|
|
89
|
+
return [];
|
|
90
|
+
return interactions.filter((interaction) => interaction.mouseEvent === mouseEvent);
|
|
91
|
+
}
|
|
92
|
+
const { executeInteraction } = useInteraction({
|
|
93
|
+
cameraSettings: camera,
|
|
94
|
+
sequences: animationSequences,
|
|
95
|
+
});
|
|
96
|
+
const handleObjectClickHandler = (createdObject, ref, event) => {
|
|
97
|
+
const clickInteractions = filterInteractionsByEvent(createdObject.interactions?.actions, "click");
|
|
98
|
+
clickInteractions.forEach((interaction) => {
|
|
99
|
+
executeInteraction({ interaction, ref, createdObject });
|
|
100
|
+
});
|
|
101
|
+
if (onObjectClick) {
|
|
102
|
+
onObjectClick(createdObject, ref, event);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
84
105
|
return (_jsx("div", { className: className, style: containerStyle, children: _jsx(Canvas, { style: {
|
|
85
106
|
backgroundColor: backgroundColor,
|
|
86
107
|
}, shadows: shadows, dpr: dpr, gl: {
|
|
87
108
|
antialias,
|
|
88
109
|
alpha: true,
|
|
89
|
-
powerPreference:
|
|
110
|
+
powerPreference: "high-performance",
|
|
90
111
|
...gl,
|
|
91
112
|
}, camera: {
|
|
92
113
|
fov,
|
|
@@ -100,6 +121,6 @@ const SceneBuilder = ({ project, width = "100%", height = "100vh", style = {}, c
|
|
|
100
121
|
if (onSceneInitialized) {
|
|
101
122
|
onSceneInitialized();
|
|
102
123
|
}
|
|
103
|
-
}, children:
|
|
124
|
+
}, children: _jsxs(ProductionScene, { physicsSettings: physicsSettings, controls: controls, children: [_jsx(LightsManager, { lights: project.lights || [] }), _jsx(EnvironmentManager, { hdrSettings: environment.hdr, timeSettings: timeSettings, visible: true, sunSystemVisible: environment.sky.sunSystem.visible, sunSize: environment.sky.sunSystem.sunSize, moonSize: environment.sky.sunSystem.moonSize, sunIntensity: environment.sky.sunSystem.intensity, castShadow: environment.sky.sunSystem.castShadow, shadowMapSize: environment.sky.sunSystem.shadowMapSize, starsSettings: environment.stars, skyControllerSettings: environment.sky.visible && !environment.sky.sunSystem.visible ? environment.sky : undefined, cloudsSettings: environment.clouds, cloudsMaterialSettings: environment.clouds.materialSettings, rainSettings: environment.rain, fogSettings: environment.fog }), _jsx(CameraController, { settings: camera }), _jsx(Ocean, { settings: environment.ocean }), _jsx(ObjectsRenderer, { cameraSettings: camera, generalObjectSettings: generalObjectSettings, createdObjects: sceneObjects, onObjectsReady: undefined, handleObjectClick: handleObjectClickHandler })] }) }) }));
|
|
104
125
|
};
|
|
105
126
|
export default SceneBuilder;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ntalmagor/3drize-viewer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"pub": "npm run build && npm publish --access public"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@ntalmagor/3drize-core": "*",
|
|
26
25
|
"@react-three/drei": "^10",
|
|
27
26
|
"@react-three/fiber": "^9",
|
|
28
27
|
"@react-three/rapier": "^2",
|
|
@@ -30,13 +29,15 @@
|
|
|
30
29
|
"three": "^0.170"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
|
-
"@
|
|
32
|
+
"@gsap/react": "^2.1.2",
|
|
34
33
|
"@react-three/drei": "^10.0.0",
|
|
35
34
|
"@react-three/fiber": "^9.0.0",
|
|
36
|
-
"@gsap/react": "^2.1.2",
|
|
37
|
-
"react": "^19.0.0",
|
|
38
35
|
"@types/react": "^19.0.0",
|
|
36
|
+
"react": "^19.0.0",
|
|
39
37
|
"three": "^0.170.0",
|
|
40
38
|
"typescript": "^5.7.2"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@ntalmagor/3drize-core": "^0.1.9"
|
|
41
42
|
}
|
|
42
43
|
}
|