Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

THREE.Geometry is not a constructor Error Aframe 1.3.0 (>1.0.4) #205

Open
smeybi opened this issue Dec 26, 2022 · 1 comment
Open

THREE.Geometry is not a constructor Error Aframe 1.3.0 (>1.0.4) #205

smeybi opened this issue Dec 26, 2022 · 1 comment

Comments

@smeybi
Copy link

smeybi commented Dec 26, 2022

With the newer Aframe versions above>1.0.4 it has an error THREE.Geometry is not a constructor for certain functions such as spring.
I'm not sure is the solution, I didn't test properly. But i have replaced: THREE.Geometry() with THREE.BufferGeometry() and tmp.fromBufferGeometry(meshes[0].geometry) with tmp = meshes[0].geometry.clone()
It seems to work.

function getGeometry (object) {
var matrix, mesh,
meshes = getMeshes(object),
tmp = new THREE.BufferGeometry(), // new THREE.Geometry(),
combined = new THREE.BufferGeometry(); // new THREE.Geometry(),

if (meshes.length === 0) return null;

// Apply scale – it can't easily be applied to a CANNON.Shape later.
if (meshes.length === 1) {
var position = new THREE.Vector3(),
quaternion = new THREE.Quaternion(),
scale = new THREE.Vector3();
if (meshes[0].geometry.isBufferGeometry) {
if (meshes[0].geometry.attributes.position
&& meshes[0].geometry.attributes.position.itemSize > 2) {
// tmp.fromBufferGeometry(meshes[0].geometry);
tmp = meshes[0].geometry.clone();
}
} else {
tmp = meshes[0].geometry.clone();
}
tmp.metadata = meshes[0].geometry.metadata;
meshes[0].updateMatrixWorld();
meshes[0].matrixWorld.decompose(position, quaternion, scale);
return tmp.scale(scale.x, scale.y, scale.z);
}

// Recursively merge geometry, preserving local transforms.
while ((mesh = meshes.pop())) {
mesh.updateMatrixWorld();
if (mesh.geometry.isBufferGeometry) {
if (mesh.geometry.attributes.position
&& mesh.geometry.attributes.position.itemSize > 2) {
var tmpGeom = new THREE.Geometry();
// tmpGeom.fromBufferGeometry(mesh.geometry);
tmpGeom = meshes.geometry.clone();
combined.merge(tmpGeom, mesh.matrixWorld);
tmpGeom.dispose();
}
} else {
combined.merge(mesh.geometry, mesh.matrixWorld);
}
}

@vincentfretin
Copy link
Collaborator

This is fixed in the community fork
https://www.npmjs.com/package/@c-frame/aframe-physics-system

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants