First, I'm Japanese student. So, please forgive my poor English. I'm developing a-frame library that make animation with anime.js in TypeScript now. When I tried to accessing Element.object3D to update value of position, TypeScript generated "Property 'object3D' does not exist on type 'Element'" error. Here is my code.
function updateValue(target: Element, attr: Attribute, value: number) {
switch (attr) {
case "PositionX":
target.object3D.position.setX(value)
case "PositionY":
target.object3D.position.setY(value)
case "PositionZ":
target.object3D.position.setZ(value)
}
I realize 'object3D' does not exist on Element but when import a-frame it exists. I tried to require("aframe") but this problem was not fixed. I apologize for the rudimentary nature of this question and my poor English, but I would be very grateful if you could answer it.
CodePudding user response:
You probably need to install @types/aframe
package, to have the typings for your typescript project.
After that, use Entity or Scene (I don't know which one is the one that you receive in updateValue
but those 2 contain object3D
.
function updateValue(target: Entity, attr: Attribute, value: number) {