最終更新:2021-02-25 (木) 14:44:11 (1153d)
A-Frame/JavaScript
https://aframe.io/docs/1.2.0/introduction/javascript-events-dom-apis.html
メモ
- Do not try to put A-Frame-related JavaScript in a raw <script> tag after <a-scene> as we would with traditional 2D scripting. If we do, we’d have to take special measures to make sure code runs at the right time (see Running Content Scripts on the Scene).
シーンのロード
- https://aframe.io/docs/1.2.0/core/scene.html#running-content-scripts-on-the-scene
var scene = document.querySelector('a-scene'); if (scene.hasLoaded) { run(); } else { scene.addEventListener('loaded', run); } function run () { var entity = scene.querySelector('a-entity'); entity.setAttribute('material', 'color', 'red'); }