Hi people
I have a web application that have a viewer of model 3D with animations but I unknow how apply programatically the animations.
In general, the model is loaded and is make the read from outputs that have the data of animation
const VIEWPORT = await createViewport({
id: "product-shapediver-viewport",
canvas: canvas,
visibility: VISIBILITY_MODE.SESSION,
});
const VIEWPORT_SESSION = await createSession({
id: `product-shapediver-session-${productSlug}`,
modelViewUrl: "π",
ticket: "π",
throwOnCustomizationError: true,
})
const OUTPUT_DADOS_MOVEL = vwS.getOutputByName('dados_movel')[0].content
const OUTPUT_DOOR_GEOMETRY = vwS.getOutputByName('door')[0].content as TModelGeometry[] | undefined
const OUTPUT_DRAWER_GEOMETRY = vwS.getOutputByName('drawer')[0].content as TModelGeometry[] | undefined
At this moment, I donβt how get the node target from model to apply the animation data/track
have focus on the push operation in ANIMATION_DATA_DOOR/DRAWER and NODE constant
d.forEach((mad, i) => {
// 3 AND 2 ARE KNOW POSITION FROM STRUCTURE OF URL FROM
// SHAPEDIVER TO GET THE ID NODE
const NODE_ID = OUTPUT_DOOR_GEOMETRY[i].href.split('/')[3 + 2]
// const NODE = vwS.node.children.find(d => d.name === NODE_ID)
const NODE = vwS.node.children?.[i] || NODE_ID
// if (!NODE) return;
if (mad['rotation_side']) {
ANIMATION_DATA_DOOR.push({
node: NODE as unknown as ITreeNode,
interpolation: 'linear',
pivot: [mad.point.X, mad.point.Y, mad.point.Z],
path: 'rotation',
times: [0, 2.5, 7.5, 10],
values: [
0, 0, 0,
14, 16, 10,
-90, -30, -12,
0, 0, 0
]
})
}
if (mad['depth']) {
ANIMATION_DATA_DRAWER.push({
node: NODE as unknown as ITreeNode,
interpolation: 'linear',
pivot: [mad.point.X, mad.point.Y, mad.point.Z],
path: 'translation',
times: [0, 2.5, 7.5, 10],
values: [
0, 0, 0,
0, 0, (mad?.depth as number) || 0,
0, 0, (mad?.depth as number) || 0,
0, 0, 0,
]
})
}
})
const data1 = new AnimationData('doors', ANIMATION_DATA_DOOR, 0, 10)
const data2 = new AnimationData('drawers', ANIMATION_DATA_DRAWER, 0, 10)
data1.repeat = true
data2.repeat = true
console.table({ data1, tracks: ANIMATION_DATA_DOOR,
am:viewport.current?.animations });
vwS.node.addData(data1)
vwS.node.addData(data2)
data1.startAnimation()
data2.startAnimation()
viewport.current?.update()
Above have the constant NODE this node should be the reference that will receive the animation, a Door and a Drawer. but how i explain above, donβt know how get the node of door and drawer
Someone with a light?