-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { addObject3DComponent } from "../utils/jsx-entity"; | ||
import { HubsWorld } from "../app"; | ||
import { EntityID } from "../utils/networking-types"; | ||
import { Mesh, MeshBasicMaterial, PlaneGeometry } from "three"; | ||
|
||
const MATERIAL_DEFAULTS = { | ||
color: "#000000", | ||
opacity: 1, | ||
transparent: false | ||
}; | ||
|
||
const PLANE_DEFAULTS = { | ||
width: 1, | ||
height: 1, | ||
material: MATERIAL_DEFAULTS | ||
}; | ||
|
||
export interface MeshBasicMaterialParams { | ||
color?: string; | ||
opacity?: number; | ||
transparent?: boolean; | ||
} | ||
|
||
export interface PlaneParams { | ||
width?: number; | ||
height?: number; | ||
material?: MeshBasicMaterialParams; | ||
} | ||
|
||
export function inflatePlane(world: HubsWorld, eid: EntityID, params: PlaneParams) { | ||
params = Object.assign({}, PLANE_DEFAULTS, params); | ||
params.material = Object.assign({}, MATERIAL_DEFAULTS, params.material); | ||
const geometry = new PlaneGeometry(params.width, params.height); | ||
const material = new MeshBasicMaterial({ ...params.material }); | ||
const obj = new Mesh(geometry, material); | ||
addObject3DComponent(world, eid, obj); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** @jsx createElementEntity */ | ||
import { Attrs, createElementEntity } from "../utils/jsx-entity"; | ||
|
||
export interface PlaneParams extends Attrs { | ||
width?: number; | ||
height?: number; | ||
material?: MeshBasicMaterialParams; | ||
} | ||
|
||
export interface MeshBasicMaterialParams extends Attrs { | ||
color?: string; | ||
opacity?: number; | ||
transparent?: boolean; | ||
// TODO Add the rest of the material properties | ||
} | ||
|
||
export function Plane({ width, height, material, name = "Plane", ...props }: PlaneParams) { | ||
return <entity name={name} cursorRaycastable plane={{ width, height, material }} {...props} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters