2.2.4 • Published 3 months ago

lesca-webgl-threejs v2.2.4

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

NPM React React React React React NPM

Why use it?

It's can build full page webgl easily. include camera light orbitControls sky sun.

Live Demo

Installation

npm install lesca-webgl-threejs --save

Usage

import Webgl from 'lesca-webgl-threejs';
import { CameraType } from 'lesca-webgl-threejs/types';

const config = {
  fps: 0,
  camera: { zoom: 30, far: 75, type: CameraType.perspective, dom: undefined },
  sky: {
    enabled: true,
    turbidity: 3.8,
    rayleigh: 2.967,
    mieCoefficient: 0.005,
    mieDirectionalG: 0.7,
    inclination: 70,
    azimuth: 180,
  },
  controls: {
    distance: { min: 13, max: 30 },
    polar: { min: -70, max: 70 },
    azimuth: { min: -Infinity, max: Infinity },
    default: {
      polar: 0,
      azimuth: 0,
    },
    offsetAzimuth: 0,
    enabled: true,
    panEasing: 100,
  },
  light: {
    ambient: {
      color: 0x5289d2,
      intensity: 0.6,
    },
    point: {
      enabled: true,
      color: 0x999999,
      intensity: 0.9,
      distance: 3,
      decay: 0.5,
      position: { x: 0, y: 3, z: 10 },
    },
    spot: {
      enabled: false,
      color: 0x999999,
      intensity: 0.9,
      distance: 3,
      decay: 0.5,
      angle: Math.PI * 0.12,
      penumbra: 1,
      position: { x: 0, y: 3, z: 0 },
    },
    shadowMapSize: 256,
    debug: true,
  },
  renderer: {
    alpha: false,
    shadowType: THREE.PCFSoftShadowMap,
    exposure: 0.5,
    outputEncoding: THREE.sRGBEncoding,
  },
  physics: false,
  stats: true,
};

const webgl = new Webgl(config);
container.appendChild(render.domElement);

Development

Config

methoddescriptiondefault
.fps:numberset fps0
.camera:objectOrthographicCamera setup.default
.sky:objectSky setup.default
.controls:objectorbitControls setup.default
.light:objectlight setup.default
.renderer:objectwebglRenderer setup.default
.physics:objectcannon-es setup.default
.stats:objectstats-js setup.default

Default camera config

keydocsdefault
zoom:numberzoom30
far:numberfar200
dom:HTMLElementHTML container
type:enum:numberorthographic or perspectiveperspective

Default sky config

keydocsdefault
enabled:booleantrue
turbidity:numbersky0
rayleigh:numbersky0.079
mieCoefficient:numbersky0.023
mieDirectionalG:numbersky0.226
inclination:numbersky70
azimuth:numbersky-102.7

Default controls config

keydocsdefault
enabled:booleanorbitControlstrue
distance:objectorbitControlsmin:30, max:30
polar:objectorbitControlsmin:35, max:35
azimuth:objectorbitControlsmin: -Infinity, max: Infinity
default:objectorbitControlspolar:0, azimuth: 0
offsetAzimuth:numbernumber0
panEasing:numbernumber100

Methods of controls

function Namedescriptionparametersreturn
.fixed(Object)Fixed angle perspective{ polar:Number, azimuth:number, target: THREE.Vector3}void
.lookAt(vec:THREE.Vector3)focus on a target pointvec:THREE.Vector3void
.chase(mesh: THREE.Mesh, height:number)camera will follow target smoothlymesh:THREE.vector3void
.lock()lock cameravoid
.unlock()unlock cameravoid
.set()set angle and distance{ polar:Number, azimuth:number, distance: number}void
.get()get angle and distance{ polar:Number, azimuth:number, distance: number}void

Default light config

keydocsdefault
ambient:objectlightdefault
spot:objectspotLightdefault
point:objectpointLightdefault
shadowMapSize:numberspotLight256
debugSpotLightHelperfalse
ambient
  • color: 0x5289d2
  • intensity: 0.6
spot
  • color: 0x999999
  • intensity: 0.9
  • position: { x: 0, y: 15, z: 0 }
  • distance: 3
  • decay: 0.5
  • angle: Math.PI * 0.12
  • penumbra: 1
point
  • color: 0x999999
  • intensity: 0.9
  • distance: 3
  • position: { x: 0, y: 15, z: 0 }
  • decay: 0.5

Default renderer config

keydocsdefault
alpha:booleanWebGLRendererfalse
shadowType:numberWebGLRendererTHREE.BasicShadowMap
exposure:numberWebGLRenderer0.5
outputEncoding:numberWebGLRendererTHREE.sRGBEncoding

Default physics config

keydocsdefault
physics:booleancannon-esfalse

Default stats config

keydocsdefault
stats:booleanstats-jsfalse

Features

  • Code Linting (eslint)
  • maintain if necessary
2.2.3

3 months ago

2.2.4

3 months ago

2.2.2

5 months ago

2.2.1

5 months ago

2.2.0

5 months ago

2.0.2

5 months ago

2.0.1

5 months ago

2.0.0

5 months ago

2.1.2

5 months ago

2.1.1

5 months ago

2.1.4

5 months ago

2.1.3

5 months ago

2.1.5

5 months ago

2.1.0

5 months ago

1.3.23

5 months ago

1.3.22

5 months ago

1.3.13

5 months ago

1.3.14

5 months ago

1.3.12

5 months ago

1.3.17

5 months ago

1.3.18

5 months ago

1.3.15

5 months ago

1.3.16

5 months ago

1.3.19

5 months ago

1.3.20

5 months ago

1.3.21

5 months ago

1.3.10

5 months ago

1.3.11

5 months ago

1.3.9

5 months ago

1.3.8

5 months ago

1.3.7

5 months ago

1.3.6

5 months ago

1.3.5

5 months ago

1.3.4

11 months ago

1.3.3

11 months ago

1.3.2

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.10

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.2.9

1 year ago

1.1.1

2 years ago

1.0.19

2 years ago

1.1.0

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.31

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago