@ntalmagor/3drize-viewer 0.1.13 → 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 +1 @@
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;AAexG,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA2HnD,CAAC;AAEF,eAAe,eAAe,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,34 +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
- import LightsManager from "./LightsManager.js";
6
- import EnvironmentManager from "./EnvironmentManager.js";
7
- import CameraController from "./CameraController.js";
8
- import Ocean from "./Ocean.js";
9
- import ObjectsRenderer from "./ObjectsRenderer.js";
10
- import { useInteraction } from "../hooks/useInteraction.js";
11
- const ProductionScene = ({ onObjectsReady, onObjectClick, gridSettings, hdr, physicsSettings, generalObjectSettings, ocean, cameraSettings, selectedLight, objects, lighting, controls, geometry, structure, sky, timeSettings, starsSettings, clouds, rainSettings, fogSettings, animationSequences, }) => {
12
- const sunSystem = sky.sunSystem;
13
- const mode = 'default';
14
- // console.log({animationSequences})
5
+ const ProductionScene = ({ physicsSettings, controls, children, }) => {
15
6
  // Interaction hook
16
- const { executeInteraction, currentAnimatedRef, glowingObjects, vanishedObjects } = useInteraction({
17
- cameraSettings,
18
- sequences: animationSequences,
19
- });
20
- function filterInteractionsByEvent(interactions, mouseEvent) {
21
- if (!interactions)
22
- return [];
23
- return interactions.filter((interaction) => interaction.mouseEvent === mouseEvent);
24
- }
25
- const handleObjectClick = (createdObject, ref, event) => {
26
- console.log('[ProductionScene] handleObjectClick:', createdObject.id);
27
- const clickInteractions = filterInteractionsByEvent(createdObject.interactions?.actions, 'click');
28
- clickInteractions.forEach((interaction) => {
29
- executeInteraction({ interaction, ref, createdObject });
30
- });
31
- onObjectClick && onObjectClick(createdObject, ref, event);
32
- };
33
- 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 }), _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 })] }));
34
8
  };
35
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;AAKnD,OAAO,KAAK,EAAa,iBAAiB,EAAe,MAAM,wBAAwB,CAAC;AAQxF,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAyK7C,CAAC;AAEF,eAAe,YAAY,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
- // import UiController from "./UiController";
10
- // import type { HtmlElement } from "~/types/uiController";
11
- const SceneBuilder = ({ project, width = "100%", height = "100vh", style = {}, className = '', onSceneInitialized, onUiElementClick, onObjectClick, }) => {
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, } = sceneCanvas;
49
- const { position, orientation, fov, near, far, } = camera;
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: 'relative',
54
- overflow: 'hidden',
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: 'high-performance',
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: _jsx(ProductionScene, { device: "desktop", onObjectsReady: undefined, gridSettings: environment.grid, hdr: environment.hdr, physicsSettings: physicsSettings, generalObjectSettings: generalObjectSettings, ocean: environment.ocean, cameraSettings: camera, selectedLight: null, objects: sceneObjects, lighting: project.lights || [], controls: controls, geometry: project.settings?.materialCreator?.geometry || null, structure: project.settings?.structure || null, sky: environment.sky, timeSettings: timeSettings, starsSettings: environment.stars, clouds: environment.clouds, rainSettings: environment.rain, fogSettings: environment.fog, onObjectClick: onObjectClick, animationSequences: animationSequences }) }) }));
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.13",
3
+ "version": "0.1.14",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",