supermedium / aframe-react

:atom: Build virtual reality experiences with A-Frame and React.
https://ngokevin.github.io/aframe-react-boilerplate/
MIT License
1.42k stars 151 forks source link

How to use "AFRAME.registerGeometry"? #125

Closed ex-tag closed 2 years ago

ex-tag commented 5 years ago

How do I register a geometry? Trying to use AFRAME.registerGeometry...

'AFRAME' is not defined
import 'aframe';
import 'aframe-extras';
import 'aframe-particle-system-component';
import 'aframe-gradient-sky';
import { Scene, Entity } from 'aframe-react';
import React, { Component, Fragment } from 'react';
import { BoxGeometry } from 'three';

AFRAME.registerGeometry('box', {
  schema: {
    depth: { default: 1, min: 0 },
    height: { default: 1, min: 0 },
    width: { default: 1, min: 0 },
    segmentsHeight: { default: 1, min: 1, max: 20, type: 'int' },
    segmentsWidth: { default: 1, min: 1, max: 20, type: 'int' },
    segmentsDepth: { default: 1, min: 1, max: 20, type: 'int' }
  },
  init: data => {
    this.geometry = new BoxGeometry(data.width, data.height, data.depth);
  }
});
samuel-zuk commented 5 years ago

include this at the top of your code: const AFRAME = window.AFRAME;