aframe-extras
Version:
Add-ons and examples for A-Frame VR.
2 lines • 3.34 kB
JavaScript
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var a=t();for(var i in a)("object"==typeof exports?exports:e)[i]=a[i]}}(self,(()=>(()=>{var e={785:e=>{e.exports=AFRAME.registerPrimitive("a-grid",{defaultComponents:{geometry:{primitive:"plane",width:75,height:75},rotation:{x:-90,y:0,z:0},material:{src:"url(https://cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v1.16.3/assets/grid.png)",repeat:"75 75"}},mappings:{width:"geometry.width",height:"geometry.height",src:"material.src"}})},683:e=>{e.exports.Primitive=AFRAME.registerPrimitive("a-ocean",{defaultComponents:{ocean:{},rotation:{x:-90,y:0,z:0}},mappings:{width:"ocean.width",depth:"ocean.depth",density:"ocean.density",amplitude:"ocean.amplitude",amplitudeVariance:"ocean.amplitudeVariance",speed:"ocean.speed",speedVariance:"ocean.speedVariance",color:"ocean.color",opacity:"ocean.opacity"}}),e.exports.Component=AFRAME.registerComponent("ocean",{schema:{width:{default:10,min:0},depth:{default:10,min:0},density:{default:10},amplitude:{default:.1},amplitudeVariance:{default:.3},speed:{default:1},speedVariance:{default:2},color:{default:"#7AD2F7",type:"color"},opacity:{default:.8}},play:function(){const e=this.el,t=this.data;let a=e.components.material;const i=new THREE.PlaneGeometry(t.width,t.depth,t.density,t.density);this.waves=[];const n=i.getAttribute("position");for(let e=0;e<n.count;e++)this.waves.push({z:n.getZ(e),ang:Math.random()*Math.PI*2,amp:t.amplitude+Math.random()*t.amplitudeVariance,speed:(t.speed+Math.random()*t.speedVariance)/1e3});a||(a={},a.material=new THREE.MeshPhongMaterial({color:t.color,transparent:t.opacity<1,opacity:t.opacity,flatShading:!0})),this.mesh=new THREE.Mesh(i,a.material),e.setObject3D("mesh",this.mesh)},remove:function(){this.el.removeObject3D("mesh")},tick:function(e,t){if(!t)return;const a=this.mesh.geometry.getAttribute("position");for(let e=0;e<a.count;e++){const i=this.waves[e],n=i.z+Math.sin(i.ang)*i.amp;a.setZ(e,n),i.ang+=i.speed*t}a.needsUpdate=!0}})},539:e=>{e.exports.Primitive=AFRAME.registerPrimitive("a-tube",{defaultComponents:{tube:{}},mappings:{path:"tube.path",segments:"tube.segments",radius:"tube.radius","radial-segments":"tube.radialSegments",closed:"tube.closed"}}),e.exports.Component=AFRAME.registerComponent("tube",{schema:{path:{default:[]},segments:{default:64},radius:{default:1},radialSegments:{default:8},closed:{default:!1}},init:function(){const e=this.el,t=this.data;let a=e.components.material;if(!t.path.length)return void console.error("[a-tube] `path` property expected but not found.");const i=new THREE.CatmullRomCurve3(t.path.map((function(e){return e=e.split(" "),new THREE.Vector3(Number(e[0]),Number(e[1]),Number(e[2]))}))),n=new THREE.TubeGeometry(i,t.segments,t.radius,t.radialSegments,t.closed);a||(a={},a.material=new THREE.MeshPhongMaterial),this.mesh=new THREE.Mesh(n,a.material),this.el.setObject3D("mesh",this.mesh)},update:function(e){Object.keys(e).length&&(this.remove(),this.init())},remove:function(){this.mesh&&this.el.removeObject3D("mesh")}})}},t={};function a(i){var n=t[i];if(void 0!==n)return n.exports;var o=t[i]={exports:{}};return e[i](o,o.exports,a),o.exports}return a(785),a(683),a(539),{}})()));
//# sourceMappingURL=aframe-extras.primitives.min.js.map