aframe-extras
aframe-extras copied to clipboard
Ocean extra nlot working on aframe 1.2.0
Hello, I was wondering if the extra's like the ocean will be updated to be used on the newer version of aframe which currently 1.2.0 please? it looks okay on 1.1.0 However All my stuff is based on 1.2.0.
Joseph
It's about the change in Three.js Version in Aframe 1.2.0, geometry.vertices to geometry.attributes.position
I changed the ocean script quickly, here the changes, hope it helps:
play: function () {
const geometry = new THREE.PlaneBufferGeometry(data.width, data.depth, data.density, data.density);
THREE.BufferGeometryUtils.mergeVertices( geometry)
this.waves = [];
for (let v, i = 2, l = geometry.attributes.position.array.length; i < l; i += 3) {
v = geometry.attributes.position.array[i]
this.waves.push({
z: v,
tick: function (t, dt) {
for (let v, vprops, i = 0,j = 2; i < this.waves.length; i ++, j += 3){
vprops = this.waves[i];
v = vprops.z + Math.sin(vprops.ang) * vprops.amp;
this.mesh.geometry.attributes.position.array[j]=v
vprops.ang += vprops.speed * dt;
}
this.mesh.geometry.attributes.position.needsUpdate = true;
}
Here the component on Glitch https://glitch.com/edit/#!/aframe-extras-1-2-0-ocean?path=index.html%3A102%3A28
Hello thank you very much. It looks awesome. I have one question my aframe scene is 3200x3200 is there a way to increase the ocean says 5000x5000? I have tried that but the pattern goes flat. Sorry I'm not much of a coder But I'm trying.
Joseph
@smeybi will you do a pull request, or should someone else open one with this code?
Fixed in #387