diff --git a/viser/client/build/asset-manifest.json b/viser/client/build/asset-manifest.json index a57d5c169..51450fd8b 100644 --- a/viser/client/build/asset-manifest.json +++ b/viser/client/build/asset-manifest.json @@ -1,13 +1,13 @@ { "files": { "main.css": "/static/css/main.82973013.css", - "main.js": "/static/js/main.9be61952.js", + "main.js": "/static/js/main.7623e1a3.js", "index.html": "/index.html", "main.82973013.css.map": "/static/css/main.82973013.css.map", - "main.9be61952.js.map": "/static/js/main.9be61952.js.map" + "main.7623e1a3.js.map": "/static/js/main.7623e1a3.js.map" }, "entrypoints": [ "static/css/main.82973013.css", - "static/js/main.9be61952.js" + "static/js/main.7623e1a3.js" ] } \ No newline at end of file diff --git a/viser/client/build/index.html b/viser/client/build/index.html index 6bd6dae13..b31fc343d 100644 --- a/viser/client/build/index.html +++ b/viser/client/build/index.html @@ -1 +1 @@ -Viser
\ No newline at end of file +Viser
\ No newline at end of file diff --git a/viser/client/src/SceneTree.tsx b/viser/client/src/SceneTree.tsx index fbf20aede..b5d8b86f5 100644 --- a/viser/client/src/SceneTree.tsx +++ b/viser/client/src/SceneTree.tsx @@ -262,24 +262,30 @@ export function SceneNodeThreeObject(props: { name: string }) { if (obj === null) return; const nodeAttributes = viewer.nodeAttributesFromName.current[props.name]; - const wxyz = nodeAttributes?.wxyz; - const position = nodeAttributes?.position; - const visibility = nodeAttributes?.visibility; + if (nodeAttributes === undefined) return; + + const visibility = nodeAttributes.visibility; + if (visibility !== undefined) { + obj.visible = visibility; + } let changed = false; - if (visibility !== undefined) obj.visible = visibility; + const wxyz = nodeAttributes.wxyz; if (wxyz !== undefined) { changed = true; obj.quaternion.set(wxyz[1], wxyz[2], wxyz[3], wxyz[0]); } + const position = nodeAttributes.position; if (position !== undefined) { changed = true; obj.position.set(position[0], position[1], position[2]); } // Update matrices if necessary. This is necessary for PivotControls. - if (changed && !obj.matrixAutoUpdate) obj.updateMatrix(); - if (changed && !obj.matrixWorldAutoUpdate) obj.updateMatrixWorld(); + if (changed) { + if (!obj.matrixAutoUpdate) obj.updateMatrix(); + if (!obj.matrixWorldAutoUpdate) obj.updateMatrixWorld(); + } }); // Clean up when done. diff --git a/viser/client/src/WebsocketInterface.tsx b/viser/client/src/WebsocketInterface.tsx index eecf96bcf..90af7535a 100644 --- a/viser/client/src/WebsocketInterface.tsx +++ b/viser/client/src/WebsocketInterface.tsx @@ -301,7 +301,7 @@ function useMessageHandler() { const name = message.name; const sendDragMessage = makeThrottledMessageSender( viewer.websocketRef, - 25 + 50 ); addSceneNodeMakeParents( new SceneNode(message.name, (ref) => ( @@ -320,14 +320,23 @@ function useMessageHandler() { depthTest={message.depth_test} opacity={message.opacity} onDrag={(l) => { + const attrs = viewer.nodeAttributesFromName.current; + if (attrs[message.name] === undefined) { + attrs[message.name] = {}; + } + const wxyz = new THREE.Quaternion(); wxyz.setFromRotationMatrix(l); const position = new THREE.Vector3().setFromMatrixPosition(l); + + const nodeAttributes = attrs[message.name]!; + nodeAttributes.wxyz = [wxyz.w, wxyz.x, wxyz.y, wxyz.z]; + nodeAttributes.position = position.toArray(); sendDragMessage({ type: "TransformControlsUpdateMessage", name: name, - wxyz: [wxyz.w, wxyz.x, wxyz.y, wxyz.z], - position: position.toArray(), + wxyz: nodeAttributes.wxyz, + position: nodeAttributes.position, }); }} />