Skip to content

Commit

Permalink
Delint
Browse files Browse the repository at this point in the history
  • Loading branch information
takahirox committed Jun 9, 2021
1 parent 431805b commit 3a5602f
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 46 deletions.
9 changes: 1 addition & 8 deletions src/components/simple-water.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@ import { SimplexNoise } from "three/examples/jsm/math/SimplexNoise";
import waterNormalsUrl from "../assets/waternormals.jpg";
import HubsTextureLoader from "../loaders/HubsTextureLoader";

const {
Mesh,
PlaneBufferGeometry,
MeshStandardMaterial,
MeshPhongMaterial,
Vector2,
RepeatWrapping
} = THREE;
const { Mesh, PlaneBufferGeometry, MeshStandardMaterial, MeshPhongMaterial, Vector2, RepeatWrapping } = THREE;

/**
* SimpleWater
Expand Down
17 changes: 10 additions & 7 deletions src/components/skybox.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const {
Mesh,
Object3D,
PMREMGenerator,
PMREMCubeUVPacker,
RGBAFormat,
Scene,
ShaderMaterial,
Expand Down Expand Up @@ -365,12 +364,16 @@ export default class Sky extends Object3D {
const skyScene = new Scene();
skyScene.add(this.sky);

const cubeCamera = new CubeCamera(1, 100000, new WebGLCubeRenderTarget(512, {
format: RGBAFormat,
magFilter: LinearFilter,
minFilter: LinearFilter,
encoding: sRGBEncoding
}));
const cubeCamera = new CubeCamera(
1,
100000,
new WebGLCubeRenderTarget(512, {
format: RGBAFormat,
magFilter: LinearFilter,
minFilter: LinearFilter,
encoding: sRGBEncoding
})
);
skyScene.add(cubeCamera);
skyScene.add(this.sky);
cubeCamera.update(renderer, skyScene);
Expand Down
4 changes: 1 addition & 3 deletions src/components/water.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ MobileWater.prototype = Object.create(THREE.Mesh.prototype);
MobileWater.prototype.constructor = THREE.Water;

async function loadWaterNormals(url) {
const texture = await new Promise((resolve, reject) =>
new HubsTextureLoader().load(url, resolve, undefined, reject)
);
const texture = await new Promise((resolve, reject) => new HubsTextureLoader().load(url, resolve, undefined, reject));
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.needsUpdate = true;
return texture;
Expand Down
2 changes: 1 addition & 1 deletion src/hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import WebXRPolyfill from "webxr-polyfill";

// WebXR Polyfill for platforms only supporting WebVR API. e.g. Desktop Firefox
// WebVR API is deprecated. We may drop such platforms support at some point.
if (!('xr' in navigator) && ('getVRDisplays' in navigator)) {
if (!("xr" in navigator) && "getVRDisplays" in navigator) {
new WebXRPolyfill({
cardboard: false
});
Expand Down
33 changes: 19 additions & 14 deletions src/loaders/HubsTextureLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,25 @@ export default class HubsTextureLoader extends THREE.TextureLoader {
loader.setCrossOrigin(this.crossOrigin);
loader.setPath(this.path);

loader.load(url, bitmap => {
texture.image = bitmap;
texture.needsUpdate = true;

// We close the image bitmap when it's uploaded to texture.
// Closed image bitmap can't be reused so we remove the cache
// added in ImageBitmapLoader.
// You can remove this line once we entirely disable THREE.Cache.
THREE.Cache.remove(this.manager.resolveURL(url));

if (onLoad !== undefined) {
onLoad(texture);
}
}, onProgress, onError);
loader.load(
url,
bitmap => {
texture.image = bitmap;
texture.needsUpdate = true;

// We close the image bitmap when it's uploaded to texture.
// Closed image bitmap can't be reused so we remove the cache
// added in ImageBitmapLoader.
// You can remove this line once we entirely disable THREE.Cache.
THREE.Cache.remove(this.manager.resolveURL(url));

if (onLoad !== undefined) {
onLoad(texture);
}
},
onProgress,
onError
);

texture.flipY = false;
return texture;
Expand Down
5 changes: 0 additions & 5 deletions src/systems/nav.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
const { Pathfinding } = require("three-pathfinding");
import qsTruthy from "../utils/qs_truthy";

const Vector3 = THREE.Vector3;
const Vector2 = THREE.Vector2;
const Face3 = THREE.Face3;
const Color = THREE.Color;

AFRAME.registerSystem("nav", {
init: function() {
this.pathfinder = new Pathfinding();
Expand Down
9 changes: 4 additions & 5 deletions src/systems/render-manager-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
// We may revert and update it when we will enable again.

export class BatchManagerSystem {
constructor(scene, renderer) {
}
constructor(/*scene, renderer*/) {}

get batchingEnabled() {
return false;
Expand All @@ -16,15 +15,15 @@ export class BatchManagerSystem {
// Ignore
}

addObject(rootObject) {
addObject(/*rootObject*/) {
return 0;
}

removeObject(rootObject) {
removeObject(/*rootObject*/) {
return;
}

tick(time) {
tick(/*time*/) {
return;
}
}
12 changes: 9 additions & 3 deletions src/utils/three-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export function setMatrixWorld(object3D, m) {
object3D.matrixWorld.copy(m);
if (object3D.parent) {
object3D.parent.updateMatrices();
object3D.matrix = object3D.matrix.copy(object3D.parent.matrixWorld).invert().multiply(object3D.matrixWorld);
object3D.matrix = object3D.matrix
.copy(object3D.parent.matrixWorld)
.invert()
.multiply(object3D.matrixWorld);
} else {
object3D.matrix.copy(object3D.matrixWorld);
}
Expand Down Expand Up @@ -287,7 +290,10 @@ export const calculateCameraTransformForWaypoint = (function() {
const detachFromWorldUp = new THREE.Matrix4();
return function calculateCameraTransformForWaypoint(cameraTransform, waypointTransform, outMat4) {
affixToWorldUp(cameraTransform, upAffixedCameraTransform);
detachFromWorldUp.copy(upAffixedCameraTransform).invert().multiply(cameraTransform);
detachFromWorldUp
.copy(upAffixedCameraTransform)
.invert()
.multiply(cameraTransform);
affixToWorldUp(waypointTransform, upAffixedWaypointTransform);
outMat4.copy(upAffixedWaypointTransform).multiply(detachFromWorldUp);
};
Expand Down Expand Up @@ -364,7 +370,7 @@ export function createPlaneBufferGeometry(width, height, widthSegments, heightSe
// but we turn this off on our texture loader since createImageBitmap in Firefox
// does not support flipping. Then we flip the uv for flipY = false texture.
if (flipY === false) {
const uv = geometry.getAttribute('uv');
const uv = geometry.getAttribute("uv");
for (let i = 0; i < uv.count; i++) {
uv.setY(i, 1.0 - uv.getY(i));
}
Expand Down

0 comments on commit 3a5602f

Please sign in to comment.