Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

[BUG] TypeError: THREE.BufferAttribute: array should be a Typed Array #46

Closed
3 tasks
IRobot1 opened this issue Feb 6, 2022 · 1 comment
Closed
3 tasks

Comments

@IRobot1
Copy link
Contributor

IRobot1 commented Feb 6, 2022

Scope

  • [ x] core
  • cannon
  • postprocessing
  • soba

Describe the bug
ERROR TypeError: THREE.BufferAttribute: array should be a Typed Array.
at new BufferAttribute (three.module.js:8981:10)
at NgtBufferAttribute.init (angular-three-core.mjs:3230:67)
at angular-three-core.mjs:3211:18
at ZoneDelegate.invoke (zone.js:372:1)
at Zone.run (zone.js:134:1)
at NgZone.runOutsideAngular (core.mjs:25371:1)
at NgtBufferAttribute.set attributeArgs [as attributeArgs] (angular-three-core.mjs:3210:21)
at NgtBufferAttribute.set args [as args] (angular-three-core-attributes.mjs:13:9)
at Object.ngOnChangesSetInput [as setInput] (core.mjs:1502:1)
at setInputsForProperty (core.mjs:10959:1)
To Reproduce
Template contains the following
<ngt-line #line="ngtLine" >
<ngt-buffer-geometry>
<ngt-buffer-attribute attach="position" [args]="[[0, 0, 0, 0, 0, - 1], 3]"></ngt-buffer-attribute>
</ngt-buffer-geometry>
<ngt-line-basic-material [parameters]="{ vertexColors: true, blending: blending }"></ngt-line-basic-material>
</ngt-line>
Get above in browser console for ngt-buffer-attribute attach="position"

Expected behavior
Should work without error. Replacing with a variable doesn't work either.

Additional context
Converting https://github.com/mrdoob/three.js/blob/master/examples/webxr_vr_cubes.html to @angular/three.
I have the whole example converted to @angular/three, but trying to replace

const geometry = new BufferGeometry();
geometry.setAttribute('position', new Float32BufferAttribute([0, 0, 0, 0, 0, - 1], 3));
geometry.setAttribute('color', new Float32BufferAttribute([0.5, 0.5, 0.5, 0, 0, 0], 3));
const material = new LineBasicMaterial({ vertexColors: true, blending: AdditiveBlending });
return new Line(geometry, material);

Want to make the track-pointer line attached to XR controller be something that can be declared, instead of hard-coded.

@IRobot1
Copy link
Contributor Author

IRobot1 commented Feb 6, 2022

After a few more tries, I figured it out. Declare a variable
position = new Float32Array([0, 0, 0, 0, 0, - 1]);
then use the following in the template
<ngt-buffer-attribute attach="position" [args]="[position, 3]">

@IRobot1 IRobot1 closed this as completed Feb 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant