aframe

How can I add a loading effect before all assets are loaded?

匆匆过客 提交于 2019-12-12 22:52:52
问题 I need to display a loading effect before all assets (image or video) are loaded in a frame. Anyone can help on this? I need JavaScript code in details if possible. 回答1: See the asset management system: https://aframe.io/docs/0.3.0/core/asset-management-system.html With that, you have a way to determine when all your resources have been fetched. <a-assets> will emit a loaded event, which you can wait on and show something in the meantime. <a-scene> <a-assets timeout="10000"> <img id=

I Want To Load Entity To Animate

孤街醉人 提交于 2019-12-12 16:38:18
问题 I am using AFrame 0.8.2 . I Want to load an animated model using like FBX Format. I tried all formats but its not working . I Imported JSON model with animation ,It Worked But its Hard to get JSON Model. So I want to Load FBX Model . Here My Cod eIn GLITCH . Please Edit The Code In Glitch And Provide A Solution . <a-scene embedded arjs='sourceType: webcam;'> <a-marker preset='hiro'> <a-entity fbx-model=”src: url(https://cdn.glitch.com/c7db968f-5d83-44e4-a392-a5c98687035a%2FNeck_Mech_Walker_by

How to load JSON data into an A-Frame component?

孤人 提交于 2019-12-12 10:59:03
问题 What's the best way to load a custom JSON file as data into an A-frame component ? For example, the JSON file may contain coordinates of points. I want to load the file as an asset and use the parsed json object in the component. {"coordinates": [{"x": 0, "y": 1, "z": 2}, // ...]} 回答1: You can define your own property type in the schema that parses data how you wish. To parse JSON from a component, create a parse function that does a JSON.parse : AFRAME.registerComponent('foo', { schema: {

Archilogic gltf model can't be loaded in a-frame

夙愿已清 提交于 2019-12-12 10:41:34
问题 I wrote a demo scene on glitch to test my exported gltf model in a-frame, but I am getting an error in the console: My code <!DOCTYPE html> <html> <head> <title>Basic Scene - A-Frame</title> <meta name="description" content="Basic Scene - A-Frame"> <script src="https://aframe.io/releases/0.6.0/aframe.min.js"></script> </head> <body> <a-scene> <a-assets> <a-asset-item id="gltfDemo" src="https://cdn.glitch.com/a3c2afff-dcc6-4918-bb73-5716b35f39b0%2Fexport.gltf?1499844855169"></a-asset-item> <a

How to pass a reference to aframe component?

强颜欢笑 提交于 2019-12-12 10:05:23
问题 I'm writing a custom aframe component to render a mesh based on a very long array of objects. Aframe documentation only lists array as an input type where you can pass an attribute and it will be parsed into an array attributename="1 2 3" I would like to pass a javascript reference into the component from the outside with something like this: const hugeArray = [{somejson}, ...] const element = document.createElement('my-component'); element.<something happens here> or create a component

Aframe - call aframe function from another javascript file

久未见 提交于 2019-12-12 06:50:12
问题 I'm trying to turn positional tracking off, and I believe that this function in the aframe code is what I'm after: checkHasPositionalTracking(); However, in my second js file (which is defined AFTER aframe.js), if I try to call that function, I receive this error: Uncaught ReferenceError: checkHasPositionalTracking is not defined 回答1: You need to call it with full reference to the window.AFRAME browser global, so use AFRAME.utils.device.checkHasPositionalTracking () in your code to access it.

Aframe: cycle through colors using array

不羁岁月 提交于 2019-12-12 06:26:28
问题 I've been trying to cycle through colors using a custom component. <script> AFRAME.registerComponent('floor-cycle', { init: function () { var sceneEl = document.querySelector('a-scene'); var floorEl = sceneEl.querySelector('#floor') status = 1; floorEl.addEventListener('click', function () { if(status==1) { floorEl.setAttribute('color', 'red'); status = 2 } else if(status==2) { floorEl.setAttribute('color', 'blue'); status = 3; } else if(status==3) { floorEl.setAttribute('color', 'green');

How do I update one value within an object using setAttribute?

混江龙づ霸主 提交于 2019-12-12 04:31:10
问题 I have an element that contains an attribute called "sound". The value of this sound attribute is an object. One of the properties in this object is "volume". In other words: <a-entity position='0 0 0' sound='src: url; on: click; volume: 2.0;'></a-entity> So it's like this: { position: '0 0 0', sound: { src: 'url', on: 'click', volume: '2.0' } } I'm using setAttribute to update the volume attribute but I don't know if there's an effective way to only target one property while not changing the

Play sound component with animation using A-Frame

穿精又带淫゛_ 提交于 2019-12-12 04:23:20
问题 I'm trying to build an A-Frame scene where a car drives by the user, and I need the sound of the car to start playing as the car starts moving. For example: <a-collada-model id="car" src="#car-dae" position="-0.7 0 -100" rotation="0 90 0"> <a-animation attribute="position" dur="7000" begin="model-loaded" fill="forwards" to="-0.7 0 20" repeat="0" ></a-animation> </a-collada-model> Can I put a sound component on the animation? If not, how should I go about having the sound play at the same time