@ntalmagor/3drize-viewer 0.1.20 → 0.1.22

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":"CustomPrimitive.d.ts","sourceRoot":"","sources":["../../src/components/CustomPrimitive.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4C,MAAM,OAAO,CAAC;AAEjE,OAAO,EAAoB,KAAK,qBAAqB,EAI5B,MAAM,wBAAwB,CAAC;AAIxD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMjC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAOrD,UAAU,oBAAoB;IAC5B,aAAa,EAAE,qBAAqB,CAAC;IACrC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvE,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CAClH;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA6ElD,CAAC;AAIH,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"CustomPrimitive.d.ts","sourceRoot":"","sources":["../../src/components/CustomPrimitive.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4C,MAAM,OAAO,CAAC;AAEjE,OAAO,EAAoB,KAAK,qBAAqB,EAKzC,MAAM,wBAAwB,CAAC;AAI3C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMjC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAOrD,UAAU,oBAAoB;IAC5B,aAAa,EAAE,qBAAqB,CAAC;IACrC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvE,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CAClH;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAgFlD,CAAC;AAIH,eAAe,eAAe,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React, { useRef, useEffect, memo, useState } from "react";
3
- import { ObjectManager } from "@ntalmagor/3drize-core";
3
+ import { ObjectManager, findById } from "@ntalmagor/3drize-core";
4
4
  // import ObjectManager from "~/utils/ObjectManager";
5
5
  import { useMaterialApplication } from "../hooks/useMaterialApplication.js";
6
6
  import MaterialLibrary from "./MaterialLibrary.js";
@@ -29,8 +29,10 @@ const CustomPrimitive = memo(({ createdObject, onObjectReady, handleObjectClick,
29
29
  const apply3driseMaterials = !useDreiMaterials;
30
30
  const willApplyMaterial = apply3driseMaterials && !!createdObject.materialSettings.materialVariant;
31
31
  const [materialReady, setMaterialReady] = useState(!willApplyMaterial);
32
+ // get initial object from ObjectManager to add to scene with primitive, then use findById to get updated reference with materials applied by useMaterialApplication
32
33
  const obj = ObjectManager.getObject(createdObject.id);
33
- useMaterialApplication(obj?.object ?? null, createdObject.materialSettings, apply3driseMaterials, () => setMaterialReady(true));
34
+ const object = findById(createdObject.id);
35
+ useMaterialApplication(object ?? null, createdObject.materialSettings, apply3driseMaterials, () => setMaterialReady(true));
34
36
  if (!obj) {
35
37
  // console.warn(`CustomPrimitive - Object with ID ${createdObject.id} not found.`);
36
38
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"GalleryLayout.d.ts","sourceRoot":"","sources":["../../src/components/GalleryLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAS,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,qBAAqB,EAAuC,MAAM,wBAAwB,CAAC;AAKzG,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,qBAAqB,CAAC;IACrC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,EACvD,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CAC1C;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAkD/C,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"GalleryLayout.d.ts","sourceRoot":"","sources":["../../src/components/GalleryLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAS,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,qBAAqB,EAAuC,MAAM,wBAAwB,CAAC;AAKzG,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,qBAAqB,CAAC;IACrC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,EACvD,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CAC1C;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAmD/C,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -13,6 +13,8 @@ const GalleryLayout = ({ createdObject, selectedFrameUrl, handleObjectClick, })
13
13
  outerFrameScale: 1,
14
14
  };
15
15
  const { frames, layoutSettings } = useMemo(() => updateCurrentLayoutSettings(galleryLayout), [galleryLayout]);
16
+ // console.log('GalleryLayout - frames:', frames);
17
+ // console.log('GalleryLayout - layoutSettings:', layoutSettings);
16
18
  return (_jsx("group", { ref: groupRef, scale: [1, 1, 1], position: [0, 0, 0], rotation: [0, 0, 0], children: frames.map((frame, index) => (_jsxs(Frame, { url: frame.url, isActive: selectedFrameUrl === frame.url, createdObject: createdObject, position: frame.position, rotation: frame.rotation, hoverSettings: { sensitivity: 0.5, applyToChildren: false }, transformEffects: animations?.transform?.effects || [], layoutSettings: layoutSettings, side: galleryLayout?.side || 2, materialSettings: materialSettings, handleObjectClick: handleObjectClick, children: [layoutSettings.geometryType !== 'none' && (_jsx(ImageGeometry, { url: frame.url, geometryType: layoutSettings.geometryType, outerFrameScale: layoutSettings.outerFrameScale })), createdObject.effects?.map((effect, effectIndex) => (_jsx(EffectsGenerator, { settings: effect }, effectIndex)))] }, index))) }));
17
19
  };
18
20
  export default GalleryLayout;
@@ -1 +1 @@
1
- {"version":3,"file":"LoadingIndicator.d.ts","sourceRoot":"","sources":["../../src/components/LoadingIndicator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAqBrD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"LoadingIndicator.d.ts","sourceRoot":"","sources":["../../src/components/LoadingIndicator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAmBrD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1,6 +1,6 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import RiseLogo from './RiseLogo.js';
3
3
  const LoadingIndicator = ({ text, fullScreen = false, animate = true, size = 80, }) => {
4
- return (_jsxs("div", { children: [text && _jsx("div", { className: "loading-text", children: text }), _jsx(RiseLogo, { size: size, animated: animate, loop: true })] }));
4
+ return (_jsxs(_Fragment, { children: [text && _jsx("div", { className: "loading-text", children: text }), _jsx(RiseLogo, { size: size, animated: animate, loop: true })] }));
5
5
  };
6
6
  export default LoadingIndicator;
@@ -4,6 +4,7 @@ import { Object3D } from "three";
4
4
  import { type ThreeEvent } from '@react-three/fiber';
5
5
  type ProjectProps = {
6
6
  projectId: string;
7
+ loadingIndicator?: React.ReactNode;
7
8
  onObjectClick?: (object: CreatedObjectSettings, ref: Object3D, event: ThreeEvent<MouseEvent>) => void;
8
9
  onObjectHover?: (object: CreatedObjectSettings, ref: Object3D) => void;
9
10
  onElementClick?: (element: HtmlElement) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectLoader.d.ts","sourceRoot":"","sources":["../../src/components/ProjectLoader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,OAAQ,EAAE,KAAK,qBAAqB,EAAkB,KAAK,WAAW,EAAwB,MAAM,wBAAwB,CAAC;AAG7H,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,KAAK,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CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IAChD,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IACvD,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;CACnC,CAAC;AAEF,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA8GzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -6,7 +6,7 @@ import { loadAssets } from "@ntalmagor/3drize-core";
6
6
  import { useMeshController } from '@ntalmagor/3drize-viewer';
7
7
  import LoadingIndicator from "./LoadingIndicator.js";
8
8
  const PROJECT_LOADER_DEBUG_PREFIX = '[ProjectLoaderDebug]';
9
- const ProjectLoader = ({ projectId, onObjectClick, onObjectHover, onElementClick, onElementHover, onSceneInitialized }) => {
9
+ const ProjectLoader = ({ projectId, onObjectClick, onObjectHover, onElementClick, onElementHover, onSceneInitialized, loadingIndicator = _jsx(LoadingIndicator, { text: "Loading project...", fullScreen: true, animate: true }) }) => {
10
10
  const [project, setProject] = useState(null);
11
11
  const meshController = useMeshController();
12
12
  useEffect(() => {
@@ -40,11 +40,11 @@ const ProjectLoader = ({ projectId, onObjectClick, onObjectHover, onElementClick
40
40
  throw new Error(`HTTP error! status: ${response.status}`);
41
41
  }
42
42
  const responseData = await response.json();
43
- console.log(PROJECT_LOADER_DEBUG_PREFIX, 'Parsed project payload', {
44
- projectId,
45
- sceneObjectsCount: responseData.sceneObjects?.length || 0,
46
- projectName: responseData.name,
47
- });
43
+ // console.log(PROJECT_LOADER_DEBUG_PREFIX, 'Parsed project payload', {
44
+ // projectId,
45
+ // sceneObjectsCount: responseData.sceneObjects?.length || 0,
46
+ // projectName: responseData.name,
47
+ // });
48
48
  console.log("Loaded project:", responseData);
49
49
  const sceneObjects = responseData.sceneObjects || [];
50
50
  const modelObjects = sceneObjects.filter(obj => obj.type === 'model');
@@ -79,7 +79,12 @@ const ProjectLoader = ({ projectId, onObjectClick, onObjectHover, onElementClick
79
79
  }
80
80
  };
81
81
  if (!project) {
82
- return _jsx(LoadingIndicator, { text: "Loading project...", fullScreen: true });
82
+ return _jsx("div", { style: {
83
+ width: '100%', height: '100%', display: 'flex',
84
+ alignItems: 'center', justifyContent: 'center',
85
+ backgroundColor: 'black',
86
+ flexDirection: 'column', gap: '1rem'
87
+ }, children: loadingIndicator });
83
88
  }
84
89
  return _jsx(_Fragment, { children: _jsx(SceneBuilder, { project: project, onSceneInitialized: onSceneInitialized, onUiElementClick: onElementClick, onUiElementHover: onElementHover, onObjectClick: onObjectClick }) });
85
90
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useMaterialApplication.d.ts","sourceRoot":"","sources":["../../src/hooks/useMaterialApplication.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAwF,gBAAgB,EAAwE,MAAM,wBAAwB,CAAC;AAEtN,eAAO,MAAM,sBAAsB,GACjC,KAAK,QAAQ,GAAG,IAAI,GAAG,SAAS,EAChC,kBAAkB,gBAAgB,EAClC,4BAA4B,OAAO,EACnC,YAAY,MAAM,IAAI,SA0FvB,CAAC"}
1
+ {"version":3,"file":"useMaterialApplication.d.ts","sourceRoot":"","sources":["../../src/hooks/useMaterialApplication.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAwF,gBAAgB,EAAwE,MAAM,wBAAwB,CAAC;AAEtN,eAAO,MAAM,sBAAsB,GACjC,KAAK,QAAQ,GAAG,IAAI,GAAG,SAAS,EAChC,kBAAkB,gBAAgB,EAClC,4BAA4B,OAAO,EACnC,YAAY,MAAM,IAAI,SA6FvB,CAAC"}
@@ -39,15 +39,19 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
39
39
  activeInstancesRef.current = [];
40
40
  };
41
41
  const handleSettingsChange = async (obj, materialSettings) => {
42
+ // console.log('Applying material with settings:', obj);
42
43
  if (!obj || !materialSettings || materialSettings.materialType === 'advanced' || !materialSettings.materialVariant)
43
44
  return;
44
45
  const applyMaterial = materialSettings.apply !== undefined ? materialSettings.apply : true;
46
+ // console.log({applyMaterial});
45
47
  // If apply is false, restore original materials
46
48
  if (!applyMaterial) {
47
49
  const objectId = obj.userData?.id;
50
+ // console.log({objectId})
48
51
  if (objectId) {
49
52
  releaseActiveInstances();
50
53
  ObjectManager.restoreOriginalMaterials(objectId);
54
+ // console.log(`Restored original materials for object ID ${objectId}`);
51
55
  }
52
56
  onApplied?.();
53
57
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ntalmagor/3drize-viewer",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",