Skip to content

Better customization of the Threejs env  #235

@remcoder

Description

@remcoder

To make a lib a better Threejs player we should allow Threejs primitives to be customized via the public api.
Care need to be taken not to be merely passing many options.

This includes:

  • Scene
  • Renderer
  • Camera
  • Controls
  • Lighting settings
  • Fog

We can either

  1. expose these objects as props
  2. allow a primitive to be injected via the constructor
  3. allow them to be customized via new constructor arguments (ex 'sceneOpts')

We can define an approach per case.

Some examples:

1 exposing as prop

If we expose the scene, it can be customized

const preview = new GCodePreview({ ... });
preview.scene.fog = new THREE.Fog( 0xcccccc, 10, 15 );

2 inject

For something like fog it makes sense to allow it to be injectable by itself

const preview = new GCodePreview({
    fog: new THREE.Fog( 0xcccccc, 10, 15 )
});

3

const preview = new GCodePreview({
    sceneOpts: { 
        fog: new THREE.Fog( 0xcccccc, 10, 15 )
    }
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions