0.6.5 • Published 4 years ago

driver-webgl v0.6.5

Weekly downloads
39
License
BSD-3-Clause
Repository
github
Last release
4 years ago

driver-webgl

WebGL driver for Rax.

Components and APIs are based on three.js design and implementation. Use markup language and declarative writing to simplify development.

Install

s

$ npm install --save driver-webgl

Usage

import {createElement, Component, render} from 'rax';
import WebGLDriver from 'driver-webgl';

class HelloWorld extends Component {
  constructor(props, context) {
    super(props, context);
    this.state = {
      cubeRotation: [0, 0, 0]
    };
    this.width = window.innerWidth;
    this.height = window.innerHeight;
    this.cameraPosition = [0, 0, 5];
  }

  onFrame = () => {
    this.setState({
      cubeRotation: [
        this.state.cubeRotation[0] + 0.01,
        this.state.cubeRotation[1] + 0.01,
        0
      ]
    });
  }

  render() {
    return (
      <scene
        width={this.width}
        height={this.height}
        onFrame={this.onFrame}
      >
        <perspective-camera
          fov={75}
          aspect={this.width / this.height}
          near={0.1}
          far={1000}
          position={this.cameraPosition}
        />
        <mesh
          rotation={this.state.cubeRotation}
        >
          <box-geometry
            width={1}
            height={1}
            depth={1}
          />
          <mesh-basic-material
            color={0x00ff00}
          />
        </mesh>
      </scene>
    );
  }
}

render(<HelloWorld />, document.body, {
  driver: WebGLDriver
});

Built-in Tags

Scenes

  • scene

Cameras

  • perspective-camera

Controls

  • orbit-controls
  • trackball-controls

Core

  • geometry
  • buffer-geometry
  • object-3d
  • raycaster

Geometries

  • box-geometry
  • cylinder-geometry
  • sphere-geometry

Lights

  • ambient-light
  • directional-light

Materials

  • line-basic-material
  • line-dashed-material
  • mesh-basic-material
  • mesh-lambert-material
  • mesh-phong-material
  • points-material

Objects

  • line
  • mesh
  • points
1.0.0-beta.0

4 years ago

0.6.5

6 years ago

0.6.4

6 years ago

0.6.3

6 years ago

0.6.2

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.4

6 years ago

0.5.2

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.20

7 years ago

0.4.19

7 years ago

0.4.18

7 years ago

0.4.17

7 years ago

0.4.16

7 years ago

0.4.15

7 years ago

0.5.0-beta

7 years ago

0.4.14

7 years ago

0.4.13

7 years ago

0.4.12

7 years ago

0.4.11

7 years ago

0.4.10

7 years ago

0.4.9

7 years ago

0.4.8

7 years ago

0.4.7

7 years ago

0.4.6

7 years ago

0.4.5

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.8

7 years ago

0.3.7

7 years ago