Skip to content

Commit

Permalink
integrate PR comments, fix syntax, change _visualize argument to number
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelybecker committed May 24, 2021
1 parent 411a4ef commit c57be8b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## Features

- Built on vanilla [threeJS](http://threejs.org/)
- Built on vanilla [Three.js](http://Three.js.org/)

- Made for WebXR (ergonomic XR [session & state management](https://github.com/plutovr/sandcastle/wiki#webxr-general-1) & easy [XR input event handling](https://github.com/plutovr/sandcastle/wiki#webxr-input-1))

Expand Down
4 changes: 0 additions & 4 deletions src/engine/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { AudioListener } from "three";
import EngineEditorCamera from "./util/cameracontrols/engineeditorcamera";
import SessionHandler from "./util/webxr/sessionhandler";
import Renderer from "./renderer";
// import Physics from "./physics/physics";
// import PhysicsSolver from './physics.worker.js';
import XRInput from "./xrinput";

export function loadScene(scene) {
Expand All @@ -20,8 +18,6 @@ export function loadScene(scene) {
Renderer.render(scene, Camera);
// INPUT
if (State.isXRSession) XRInput.Update();
// PHYSICS
// if (!State.isPaused) Physics.Update();

// TRAVERSE UPDATE METHODS IN SCENE OBJECTS
scene.traverse(obj => {
Expand Down
19 changes: 9 additions & 10 deletions src/engine/util/webxr/raycaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Matrix4,
} from "three";

/** ThreeJS Line, extended with an Update method */
/** Three.js Line, extended with an Update method */
class SCLine extends Line {
constructor(
bufferGeo: THREE.BufferGeometry,
Expand All @@ -19,7 +19,7 @@ class SCLine extends Line {
}

/**
* Sandcastle's own Raycaster; WebXR-friendly syntactic sugar over threeJS's Raycaster
* Sandcastle's own Raycaster; WebXR-friendly syntactic sugar over Three.js's Raycaster
* @extends Raycaster
*/
export class SCRaycaster extends Raycaster {
Expand All @@ -36,15 +36,15 @@ export class SCRaycaster extends Raycaster {
/**
* Construct a Sandcastle Raycaster.
* @param originObject - object to raycast from
* @param target - object(s) to raycast to. Can be a mesh, a mesh array or a Box3.
* @param [direction] - The normalized direction vector that gives direction to the ray.
* @param target - object(s) to raycast to. Can be a Mesh, a Mesh array or a Box3.
* @param [direction] - The normalized direction vector that gives direction to the ray. Default value is new Vector3(0,0,-1).
* @param [isRecursive] - If true, it also checks all descendants. Otherwise it only checks intersection with the object. Default is true.
* @param [near] - All results returned are further away than near. Near can't be negative. Default value is 0.1.
* @param [far] - All results returned are closer than far. Far can't be lower than near. Default value is 10.
*/
constructor(
originObject: THREE.Mesh | THREE.Group,
target: THREE.Mesh | Array<THREE.Mesh> | THREE.Box3, // due to original polymorphism in THREE.Raycaster(), see below
target: THREE.Mesh | Array<THREE.Mesh> | THREE.Box3,
direction: THREE.Vector3 = new Vector3(0, 0, -1),
isRecursive: boolean = true,
near: number = 0.1,
Expand All @@ -67,7 +67,7 @@ export class SCRaycaster extends Raycaster {
this._isTargetBox3 = this._target.hasOwnProperty("isBox3");
}

/** get intersections of origin object with target object or array.
/** Get intersections of origin object with target object or array.
* Usually run within the update loop or as the result of an event.
* Will return a bool if intersects against a Box3, and an array if intersecting against scene objects.
* */
Expand All @@ -84,17 +84,16 @@ export class SCRaycaster extends Raycaster {
}

/**
* a helper method for visualizing raycaster rays
* A helper method for visualizing raycaster rays
* @param color - visualizing ray color
* @param onlyWhenHit - whether ray should be visualized only when a raycast hits the target or always
*/
visualize(color = "0xffffff", onlyWhenHit = false): void {
visualize(color = 0xffffff, onlyWhenHit = false): void {
const lineGeo = new BufferGeometry().setFromPoints([
new Vector3(0, 0, 0),
new Vector3(0, 0, -1),
]);
const colorValue = parseInt(color.replace("#", "0x"), 16);
const lineMat = new LineBasicMaterial({ color: colorValue });
const lineMat = new LineBasicMaterial({ color });
const _visualizedRaycast = new SCLine(lineGeo, lineMat);
_visualizedRaycast.name = "line";
if (onlyWhenHit) {
Expand Down
13 changes: 7 additions & 6 deletions src/examples/artovr/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ scene.init = () => {
const water = new Water(waterGeometry, {
textureWidth: 512,
textureHeight: 512,
waterNormals: new TextureLoader().load(WaterNormalsTexture, function (
texture
) {
texture.wrapS = texture.wrapT = RepeatWrapping;
}),
waterNormals: new TextureLoader().load(
WaterNormalsTexture,
function (texture) {
texture.wrapS = texture.wrapT = RepeatWrapping;
}
),
alpha: 1.0,
sunDirection: light.position.clone().normalize(),
sunColor: 0xffffff,
Expand All @@ -72,7 +73,7 @@ scene.init = () => {
water.position.y = -3;
scene.add(water);

// Atmosphere / day-night cycle. Custom XRCubeCamera component that handles XR rendering, soon merged to threeJS:
// Atmosphere / day-night cycle. Custom XRCubeCamera component that handles XR rendering, soon merged to Three.js:
const sky = new Sky();
const uniforms = sky.material.uniforms;
uniforms["turbidity"].value = 10;
Expand Down
2 changes: 1 addition & 1 deletion src/examples/daynightcycle/cloud.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// lovely clouds courtesy of @dghez from https://github.com/dghez/THREEJS_Procedural-clouds/
// lovely clouds courtesy of @dghez from https://github.com/dghez/Three.js_Procedural-clouds/
// tutorial https://tympanus.net/codrops/2020/01/28/how-to-create-procedural-clouds-using-three-js-sprites/

import {
Expand Down
2 changes: 1 addition & 1 deletion webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ module.exports = {
}),
],
resolve: {
extensions: [".js", ".es6", "ts"],
extensions: [".js", ".es6", ".ts"],
},
};

0 comments on commit c57be8b

Please sign in to comment.