@ntalmagor/3drize-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.
@@ -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,6 +1,6 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, 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 (_jsx("div", { children: _jsx(RiseLogo, { size: size, animated: animate, loop: true }) }));
4
+ return (_jsxs("div", { children: [text && _jsx("div", { className: "loading-text", children: text }), _jsx(RiseLogo, { size: size, animated: animate, loop: true })] }));
5
5
  };
6
6
  export default LoadingIndicator;
@@ -1 +1 @@
1
- {"version":3,"file":"useCameraAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useCameraAnimation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAGtD,OAAO,EAAW,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAO5G,UAAU,yBAAyB;I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e,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;CAChC;AAED,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,WAAW,CAAC,EAAE,eAAe,GAAG,YAAY,CAAC;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,kBAAkB,GAAI,UAAS,yBAA8B,EAAE,cAAa,WAA+B;;;+BA0MpF;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;4BApKhD,qBAAqB,aACnB,MAAM,SACV,MAAM,iBACG,YAAY;kCAwHjB,YAAY,aACX,MAAM,SACV,MAAM;wCAgCA,eAAe,aACjB,MAAM,SACV,MAAM;wBAuCR,MAAM,aACA,MAAM,SACV,MAAM;qBAOL,YAAY,aACV,OAAO,aACN,MAAM,SACV,MAAM;gCA2BL,YAAY,UACZ,MAAM,eACF,MAAM,aACR,MAAM,aACL,MAAM,SACV,MAAM;;;CA4EhB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -10,15 +10,18 @@ export const useCameraAnimation = (options = {}, cameraState = {}) => {
10
10
  // const cameraState = useAppSelector(selectCamera);
11
11
  const { interpolateProperty } = useMouseHandlers();
12
12
  const orbitControls = useOrbitControls();
13
- const cameraRef = useRef(cameraManager.getCamera());
13
+ const cameraRef = useRef(null);
14
14
  const animationRef = useRef(null);
15
15
  const isAnimatingRef = useRef(false);
16
16
  const handlers = cameraState.handlers;
17
- // Update camera reference when Three.js camera changes
17
+ // Keep cameraRef synced with the singleton. The hook may be initialized
18
+ // before the host component's effect calls cameraManager.setCamera(...),
19
+ // so a one-shot backfill races and leaves the ref null in production.
18
20
  useEffect(() => {
19
- if (!cameraRef.current) {
21
+ cameraRef.current = cameraManager.getCamera();
22
+ return cameraManager.subscribe(() => {
20
23
  cameraRef.current = cameraManager.getCamera();
21
- }
24
+ });
22
25
  }, []);
23
26
  // Kill any running animation
24
27
  const killAnimation = () => {
@@ -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"}
@@ -6,7 +6,7 @@
6
6
  // Three.js object. Uses shared utilities from materialApplicationUtils.
7
7
  //
8
8
  import { useEffect, useRef } from 'react';
9
- import { createAndApplyMaterial, MATERIAL_INSTANCE_KEY, MaterialRegistryAPI, ObjectManager, resolveTextures, traverseSkippingEdges } from '@ntalmagor/3drize-core';
9
+ import { createAndApplyMaterial, MATERIAL_INSTANCE_KEY, MaterialRegistryAPI, ObjectManager, resolveTextures } from '@ntalmagor/3drize-core';
10
10
  export const useMaterialApplication = (obj, materialSettings, shouldApply3driseMaterial, onApplied) => {
11
11
  // Track all material instances we've created so we can release them on change/unmount
12
12
  const activeInstancesRef = useRef([]);
@@ -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;
@@ -56,11 +60,11 @@ export const useMaterialApplication = (obj, materialSettings, shouldApply3driseM
56
60
  // 1. Resolve textures using shared utility (registry-driven TextureResolver)
57
61
  const resolvedSettings = await resolveTextures(variant, materialSettings);
58
62
  // 2. Traverse the object tree and apply material to any child with .material.
59
- traverseSkippingEdges(obj, true, (child) => {
60
- if (child.material) {
61
- applyMaterialToChild(child, variant, resolvedSettings);
62
- }
63
- });
63
+ // traverseSkippingEdges(obj, true, (child: any) => {
64
+ // if (child.material) {
65
+ // applyMaterialToChild(child, variant, resolvedSettings);
66
+ // }
67
+ // });
64
68
  onApplied?.();
65
69
  };
66
70
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ntalmagor/3drize-viewer",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",