mirror of
https://github.com/WhitestormJS/whs.js.git
synced 2026-02-01 16:57:32 +00:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
cb7485e009
25
README.md
25
README.md
@ -24,11 +24,6 @@ Community chat. [Join us!][discord-url]
|
||||
|
||||
### Basic setup
|
||||
|
||||
```bash
|
||||
# Install npm version
|
||||
$ npm install whs --save-dev
|
||||
```
|
||||
|
||||
Download the [minified library](https://raw.githubusercontent.com/WhitestormJS/whs.js/dev/build/whs.min.js) or link the one from [CDN](https://cdnjs.com/libraries/whitestorm.js)
|
||||
|
||||
```html
|
||||
@ -102,6 +97,26 @@ $ npm install whs
|
||||
* ✔️ **Integrated [Three.js](https://threejs.org/) rendering engine**
|
||||
* :revolving_hearts: Work with whs.js and Three.js at the same time
|
||||
|
||||
### External Modules
|
||||
|
||||
|Name|Status|Description|
|
||||
|:--:|:----:|:----------|
|
||||
|[whs-module-statsjs][statsjs]|![statsjs-npm]|WhitestormJS module for JavaScript Performance Monitor ⚡⌛|
|
||||
|[whs-module-dat.gui][datgui]|![datgui-npm]|User Interface for runtime editing properties 🔑🛠🔩|
|
||||
|[physics-module-ammonext][physics-ammonext]|![physics-ammonext-npm]|Physics module based on [Ammo.js](https://github.com/kripken/ammo.js/)|
|
||||
|[whs-module-audio][audio]| WIP |Audio module for 3D positional sound 🔉|
|
||||
|[whs-vrkit][vrkit]|![physics-ammonext-npm]|Module for Virtual Reality|
|
||||
|
||||
[statsjs]: https://github.com/WhitestormJS/whs.js/tree/dev/modules/whs-module-statsjs
|
||||
[statsjs-npm]: https://img.shields.io/npm/v/whs-module-statsjs.svg?style=flat-square
|
||||
[datgui]: https://github.com/WhitestormJS/whs.js/tree/dev/modules/whs-module-dat.gui
|
||||
[datgui-npm]: https://img.shields.io/npm/v/whs-module-dat.gui.svg?style=flat-square
|
||||
[physics-ammonext]: https://github.com/WhitestormJS/physics-module-ammonext
|
||||
[physics-ammonext-npm]: https://img.shields.io/npm/v/physics-module-ammonext.svg?style=flat-square
|
||||
[audio]: https://github.com/WhitestormJS/whs.js/tree/dev/modules/whs-module-audio
|
||||
[vrkit]: https://github.com/WhitestormJS/whs.js/tree/dev/modules/whs-vrkit
|
||||
[vrkit-npm]: https://img.shields.io/npm/v/whs-vrkit.svg?style=flat-square
|
||||
|
||||
### Donate
|
||||
|
||||
[![OpenCollective Backers][backer-badge]][backer-url]
|
||||
|
||||
22
types/components/cameras/CubeCamera.d.ts
vendored
Normal file
22
types/components/cameras/CubeCamera.d.ts
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
import {
|
||||
CameraComponent,
|
||||
CameraComponentParams
|
||||
} from '../../core';
|
||||
|
||||
import {CubeCamera as CubeCameraNative} from 'three';
|
||||
|
||||
interface CubeCameraParams extends CameraComponentParams {
|
||||
near?: number,
|
||||
far?: number,
|
||||
cubeResolution?: number
|
||||
}
|
||||
|
||||
export class CubeCamera extends CameraComponent {
|
||||
|
||||
/**
|
||||
* @param params
|
||||
*/
|
||||
constructor(params?: CubeCameraParams);
|
||||
|
||||
build(): CubeCameraNative;
|
||||
}
|
||||
25
types/components/cameras/OrthographicCamera.d.ts
vendored
Normal file
25
types/components/cameras/OrthographicCamera.d.ts
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
import {
|
||||
CameraComponent,
|
||||
CameraComponentParams
|
||||
} from '../../core';
|
||||
|
||||
import {OrthographicCamera as OrthographicCameraNative} from 'three';
|
||||
|
||||
interface OrthographicCameraParams extends CameraComponentParams {
|
||||
near?: number,
|
||||
far?: number,
|
||||
left?: number,
|
||||
right?: number,
|
||||
top?: number,
|
||||
bottom?: number
|
||||
}
|
||||
|
||||
export class OrthographicCamera extends CameraComponent {
|
||||
|
||||
/**
|
||||
* @param params
|
||||
*/
|
||||
constructor(params?: OrthographicCameraParams);
|
||||
|
||||
build(): OrthographicCameraNative;
|
||||
}
|
||||
23
types/components/cameras/PerspectiveCamera.d.ts
vendored
Normal file
23
types/components/cameras/PerspectiveCamera.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
import {
|
||||
CameraComponent,
|
||||
CameraComponentParams
|
||||
} from '../../core';
|
||||
|
||||
import {PerspectiveCamera as PerspectiveCameraNative} from 'three';
|
||||
|
||||
interface PerspectiveCameraParams extends CameraComponentParams {
|
||||
near?: number,
|
||||
far?: number,
|
||||
fov?: number,
|
||||
aspect?: number
|
||||
}
|
||||
|
||||
export class PerspectiveCamera extends CameraComponent {
|
||||
|
||||
/**
|
||||
* @param params
|
||||
*/
|
||||
constructor(params?: PerspectiveCameraParams);
|
||||
|
||||
build(): PerspectiveCameraNative;
|
||||
}
|
||||
1
types/components/cameras/index.d.ts
vendored
Normal file
1
types/components/cameras/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export * from './CubeCamera';
|
||||
2
types/components/index.d.ts
vendored
Normal file
2
types/components/index.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './meshes';
|
||||
export * from './cameras';
|
||||
21
types/components/meshes/Box.d.ts
vendored
Normal file
21
types/components/meshes/Box.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
import {MeshComponent, MeshParameters} from '../../core/MeshComponent';
|
||||
import {Material} from 'three';
|
||||
|
||||
interface BoxParameters extends MeshParameters {
|
||||
geometry?: {
|
||||
width?: number;
|
||||
height?: number;
|
||||
depth?: number;
|
||||
widthSegments?: number;
|
||||
heightSegments?: number;
|
||||
depthSegments?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export class Box extends MeshComponent {
|
||||
|
||||
/**
|
||||
* @param params
|
||||
*/
|
||||
constructor(params?: BoxParameters);
|
||||
}
|
||||
21
types/components/meshes/Sphere.d.ts
vendored
Normal file
21
types/components/meshes/Sphere.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
import {MeshComponent, MeshParameters} from '../../core/MeshComponent';
|
||||
|
||||
interface SphereParameter extends MeshParameters {
|
||||
geometry?: {
|
||||
radius?: number;
|
||||
widthSegments?: number;
|
||||
heightSegments?: number;
|
||||
phiStart?: number;
|
||||
phiLength?: number;
|
||||
thetaStart?: number;
|
||||
thetaLength?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export class Sphere extends MeshComponent {
|
||||
|
||||
/**
|
||||
* @param params
|
||||
*/
|
||||
constructor(params?: SphereParameter);
|
||||
}
|
||||
2
types/components/meshes/index.d.ts
vendored
Normal file
2
types/components/meshes/index.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './Box';
|
||||
export * from './Sphere';
|
||||
43
types/core/CameraComponent.d.ts
vendored
43
types/core/CameraComponent.d.ts
vendored
@ -1,45 +1,34 @@
|
||||
import {Component} from './Component';
|
||||
import {CompositionError} from '../core'
|
||||
|
||||
export interface defaults {
|
||||
build: true;
|
||||
export interface CameraComponentParams {
|
||||
build?: boolean;
|
||||
|
||||
position: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
position?: {
|
||||
x?: number,
|
||||
y?: number,
|
||||
z?: number
|
||||
};
|
||||
|
||||
rotation: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
rotation?: {
|
||||
x?: number,
|
||||
y?: number,
|
||||
z?: number
|
||||
};
|
||||
}
|
||||
|
||||
export class CameraComponent extends Component {
|
||||
/*
|
||||
* Creates a new CameraComponent
|
||||
* TODO define params & instuctions interface
|
||||
* TODO define instuctions interface
|
||||
*/
|
||||
constructor(params?: object, defaults?: defaults, instructions?: object);
|
||||
constructor(params?: CameraComponentParams, defaults?: CameraComponentParams, instructions?: object);
|
||||
|
||||
/*
|
||||
* TODO
|
||||
*/
|
||||
build(): Error;
|
||||
build(): CompositionError;
|
||||
|
||||
/*
|
||||
* TODO
|
||||
*/
|
||||
wrap(): any;
|
||||
wrap(): Promise<CameraComponent>;
|
||||
|
||||
/*
|
||||
* TODO
|
||||
*/
|
||||
copy(source: Component): CameraComponent;
|
||||
copy(source: CameraComponent): CameraComponent;
|
||||
|
||||
/*
|
||||
* TODO
|
||||
*/
|
||||
clone(): CameraComponent;
|
||||
}
|
||||
|
||||
8
types/core/Component.d.ts
vendored
8
types/core/Component.d.ts
vendored
@ -1,10 +1,6 @@
|
||||
import {ModuleSystem} from './ModuleSystem';
|
||||
import {App} from './App';
|
||||
|
||||
export class AddPromise {
|
||||
// TODO
|
||||
}
|
||||
|
||||
export class Component extends ModuleSystem {
|
||||
/**
|
||||
*
|
||||
@ -16,12 +12,12 @@ export class Component extends ModuleSystem {
|
||||
* Notes: As we work in 3D space - we have an App and objects it contains.
|
||||
* The App is the parent, objects are its children.
|
||||
*/
|
||||
addTo(parent: App): AddPromise;
|
||||
addTo(parent: App): Promise<Component>;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
add(object: object): AddPromise;
|
||||
add(object: object): Promise<Component>;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
|
||||
18
types/core/MeshComponent.d.ts
vendored
18
types/core/MeshComponent.d.ts
vendored
@ -1,11 +1,27 @@
|
||||
import {Component} from './Component';
|
||||
import {CompositionError} from './errors';
|
||||
import {Material} from 'three';
|
||||
|
||||
interface MeshParameters {
|
||||
material?: Material,
|
||||
|
||||
shadow?: {
|
||||
receive?: boolean,
|
||||
cast?: boolean
|
||||
},
|
||||
|
||||
position?: {
|
||||
x?: number,
|
||||
y?: number,
|
||||
z?: number
|
||||
}
|
||||
}
|
||||
|
||||
export class MeshComponent extends Component {
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
constructor(params: object, defaults?: object, instructions?: object);
|
||||
constructor(params?: MeshParameters, defaults?: object, instructions?: object);
|
||||
|
||||
/**
|
||||
* TODO explain why error
|
||||
|
||||
8
types/index.d.ts
vendored
8
types/index.d.ts
vendored
@ -1,9 +1,9 @@
|
||||
// Type definitions for WhitestormJs 2.0
|
||||
// Project: https://github.com/WhitestormJS/whitestorm.js
|
||||
// Type definitions for WhitestormJS 2.0
|
||||
// Project: https://github.com/WhitestormJS/whs.js
|
||||
// Definitions by: Hirako <https://github.com/hirako2000>
|
||||
// Definitions: https://github.com//DefinitelyTyped
|
||||
|
||||
export * from "./core";
|
||||
export * from './core';
|
||||
export * from './components';
|
||||
|
||||
// For UMD - global space
|
||||
export as namespace WHS;
|
||||
|
||||
@ -1,19 +1,35 @@
|
||||
import * as WHS from "./core";
|
||||
import {
|
||||
Loop,
|
||||
Component,
|
||||
App,
|
||||
CameraComponent,
|
||||
LightComponent,
|
||||
MeshComponent
|
||||
} from "./core";
|
||||
import {MeshStandardMaterial} from 'three';
|
||||
|
||||
const app = new WHS.App();
|
||||
import {
|
||||
Box,
|
||||
Sphere,
|
||||
CubeCamera,
|
||||
OrthographicCamera,
|
||||
PerspectiveCamera
|
||||
} from './components';
|
||||
|
||||
const app = new App();
|
||||
app.start();
|
||||
|
||||
let loop = new WHS.Loop(() => {});
|
||||
loop = new WHS.Loop(() => {}, true);
|
||||
let loop = new Loop(() => {});
|
||||
loop = new Loop(() => {}, true);
|
||||
|
||||
loop.start(app);
|
||||
loop.stop(app);
|
||||
loop.execute();
|
||||
|
||||
const component = new WHS.Component();
|
||||
const component = new Component();
|
||||
component.addTo(app);
|
||||
component.clone();
|
||||
const component2 = new WHS.Component();
|
||||
const component2 = new Component();
|
||||
component.copy(component2);
|
||||
|
||||
// Testing parent of component (ModuleSystem)
|
||||
@ -25,17 +41,56 @@ component.disposeModule(null);
|
||||
component.disposeModules();
|
||||
component.module(null).disposeModules();
|
||||
|
||||
const camera = new WHS.CameraComponent();
|
||||
const camera = new CameraComponent();
|
||||
const clonedCamera = camera.clone();
|
||||
|
||||
const light = new WHS.LightComponent({});
|
||||
const light = new LightComponent({});
|
||||
const clonedLight = light.clone();
|
||||
const copiedLight = light.copy(clonedLight);
|
||||
copiedLight.wrap();
|
||||
copiedLight.addTo(app);
|
||||
|
||||
const mesh = new WHS.MeshComponent({});
|
||||
const mesh = new MeshComponent({});
|
||||
mesh.addTo(app);
|
||||
mesh.clone();
|
||||
mesh.copy({});
|
||||
mesh.build();
|
||||
|
||||
const box = new Box({
|
||||
position: {
|
||||
x: 1
|
||||
},
|
||||
material: new MeshStandardMaterial()
|
||||
});
|
||||
box.addTo(app);
|
||||
|
||||
const sphere = new Sphere({
|
||||
position: {
|
||||
x: 1
|
||||
},
|
||||
material: new MeshStandardMaterial()
|
||||
});
|
||||
sphere.addTo(app);
|
||||
|
||||
const cubeCamera = new CubeCamera({
|
||||
build: false,
|
||||
|
||||
position: {
|
||||
x: 1,
|
||||
y: 10,
|
||||
z: 0
|
||||
}
|
||||
});
|
||||
const nativeCubeCamera = cubeCamera.build();
|
||||
|
||||
const orthographicCamera = new OrthographicCamera({
|
||||
build: false,
|
||||
far: 100
|
||||
});
|
||||
const orthographicCameraNative = orthographicCamera.build();
|
||||
|
||||
const perspectiveCamera = new PerspectiveCamera({
|
||||
build: false,
|
||||
far: 100
|
||||
});
|
||||
const perspectiveCameraNative = orthographicCamera.build();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user