Skip to content

Commit

Permalink
updated three defaultup
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewJSchoen committed Jun 6, 2022
1 parent 62f7e7e commit 2e7921f
Show file tree
Hide file tree
Showing 56 changed files with 2,645 additions and 2,843 deletions.
35 changes: 31 additions & 4 deletions dist/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ var _postprocessing = require("@react-three/postprocessing");

var _MaterialMaker = require("./Util/MaterialMaker");

var _lamina = require("lamina");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

// import { GhostMaterial } from './Util/MaterialMaker';
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

var GENERIC_SHAPES = ['cube', 'cylinder', 'sphere', 'capsule', 'arrow'];

var _default = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, forwardedRef) {
Expand Down Expand Up @@ -65,7 +68,6 @@ var _default = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, forwardedRef)
var time = clock.getElapsed() * 1000;

if (ref.current) {
// console.log(ref.current)
ref.current.position.set(position ? position.x : typeof item.position.x === 'function' ? item.position.x(time) : item.position.x, position ? position.y : typeof item.position.y === 'function' ? item.position.y(time) : item.position.y, position ? position.z : typeof item.position.z === 'function' ? item.position.z(time) : item.position.z);
ref.current.quaternion.set(rotation ? rotation.x : typeof item.rotation.x === 'function' ? item.rotation.x(time) : item.rotation.x, rotation ? rotation.y : typeof item.rotation.y === 'function' ? item.rotation.y(time) : item.rotation.y, rotation ? rotation.z : typeof item.rotation.z === 'function' ? item.rotation.z(time) : item.rotation.z, rotation ? rotation.w : typeof item.rotation.w === 'function' ? item.rotation.w(time) : item.rotation.w);
ref.current.scale.set(scale ? scale.x : typeof item.scale.x === 'function' ? item.scale.x(time) : item.scale.x, scale ? scale.y : typeof item.scale.y === 'function' ? item.scale.y(time) : item.scale.y, scale ? scale.z : typeof item.scale.z === 'function' ? item.scale.z(time) : item.scale.z);
Expand Down Expand Up @@ -122,20 +124,25 @@ var Part = function Part(_ref2) {
var wireframe = (0, _SceneContext.useSceneStore)((0, _react.useCallback)(function (state) {
return state.items[objectKey].wireframe;
}, [objectKey]));
var colorOverlay = (0, _SceneContext.useSceneStore)((0, _react.useCallback)(function (state) {
return state.items[objectKey].colorOverlay;
}, [objectKey]));
var color = (0, _SceneContext.useSceneStore)((0, _react.useCallback)(function (state) {
return state.items[objectKey].color;
}, [objectKey]));
var materialOverride = color !== undefined;
var frontRef = (0, _react.useRef)();
var backRef = (0, _react.useRef)();
var colorRef = (0, _react.useRef)();
var clock = (0, _SceneContext.useSceneStore)(function (state) {
return state.clock;
});
(0, _fiber.useFrame)((0, _react.useCallback)(function () {
// Outside of react rendering, adjust the color/material.
var time = clock.getElapsed() * 1000;

if (!ghost) {
if (colorOverlay) {
(0, _Helpers.updateColorOverlay)(colorRef, color, time);
} else if (!ghost && !colorOverlay) {
(0, _Helpers.updateShapeMaterial)(backRef, color, time);
(0, _Helpers.updateShapeMaterial)(frontRef, color, time);
}
Expand All @@ -151,7 +158,27 @@ var Part = function Part(_ref2) {
castShadow: false,
receiveShadow: false
});
} else if (colorOverlay) {
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("mesh", {
key: "I",
ref: frontRef,
geometry: part.geometry,
scale: part.scale,
castShadow: true,
receiveShadow: true,
wireframe: wireframe
}, /*#__PURE__*/_react.default.createElement(_lamina.LayerMaterial, _extends({
lighting: "physical"
}, part.material), part.material.map !== null && /*#__PURE__*/_react.default.createElement(_lamina.Texture, {
map: part.material.map,
alpha: 1
}), /*#__PURE__*/_react.default.createElement(_lamina.Color, {
ref: colorRef,
color: color,
alpha: color.a
}))));
} else if (materialOverride) {
//third option ? orginal material , color overlay ?
return /*#__PURE__*/_react.default.createElement("group", {
up: [0, 0, 1]
}, /*#__PURE__*/_react.default.createElement("mesh", {
Expand Down
2 changes: 1 addition & 1 deletion dist/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

THREE.Object3D.DefaultUp = new THREE.Vector3(0, 0, 1);
THREE.Object3D.DefaultUp.set(0, 0, 1);

function Loading() {
var _useProgress = (0, _drei.useProgress)(),
Expand Down
14 changes: 14 additions & 0 deletions dist/Util/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
});
exports.createGenericShape = void 0;
exports.objectMap = objectMap;
exports.updateColorOverlay = updateColorOverlay;
exports.updateShapeMaterial = void 0;
exports.useCombinedRefs = useCombinedRefs;

Expand All @@ -25,6 +26,19 @@ function objectMap(object, mapFn) {
}, {});
}

function updateColorOverlay(ref, color, time) {
if (ref.current && color) {
var r = typeof color.r === 'function' ? color.r(time) / 255 : color.r / 255;
var g = typeof color.g === 'function' ? color.g(time) / 255 : color.g / 255;
var b = typeof color.b === 'function' ? color.b(time) / 255 : color.b / 255;
var alpha = typeof color.a === 'function' ? color.a(time) : color.a;
ref.current.color.r = r;
ref.current.color.g = g;
ref.current.color.b = b;
ref.current.alpha = alpha;
}
}

var updateShapeMaterial = function updateShapeMaterial(ref, color, time) {
if (ref.current && color) {
var r = typeof color.r === 'function' ? color.r(time) / 255 : color.r / 255;
Expand Down
2 changes: 0 additions & 2 deletions docs/126.978f8053.iframe.bundle.js

This file was deleted.

2 changes: 2 additions & 0 deletions docs/14.518e0ab0ca65412081fb.manager.bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/256.4f774a85.iframe.bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/256.c754e93bb92b8e0b1114.manager.bundle.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/273.924ffc07.iframe.bundle.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions docs/273.924ffc07.iframe.bundle.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
2 changes: 0 additions & 2 deletions docs/278.ea99bf48.iframe.bundle.js

This file was deleted.

2 changes: 2 additions & 0 deletions docs/326.a414b813.iframe.bundle.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,47 @@ object-assign
* @license MIT
*/

/*!
* assign-symbols <https://github.com/jonschlinkert/assign-symbols>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/

/*!
* for-in <https://github.com/jonschlinkert/for-in>
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
*/

/*!
* get-value <https://github.com/jonschlinkert/get-value>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/

/*!
* https://github.com/es-shims/es5-shim
* @license es5-shim Copyright 2009-2020 by contributors, MIT License
* see https://github.com/es-shims/es5-shim/blob/master/LICENSE
*/

/*!
* is-extendable <https://github.com/jonschlinkert/is-extendable>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/

/*!
* is-extendable <https://github.com/jonschlinkert/is-extendable>
*
* Copyright (c) 2015-2017, Jon Schlinkert.
* Released under the MIT License.
*/

/*!
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
*
Expand All @@ -31,6 +66,20 @@ object-assign
* Released under the MIT License.
*/

/*!
* set-value <https://github.com/jonschlinkert/set-value>
*
* Copyright (c) 2014-2015, 2017, Jon Schlinkert.
* Released under the MIT License.
*/

/*!
* split-string <https://github.com/jonschlinkert/split-string>
*
* Copyright (c) 2015-2017, Jon Schlinkert.
* Released under the MIT License.
*/

/*!
Custom build of Typr.ts (https://github.com/fredli74/Typr.ts) for use in Troika text rendering.
Original MIT license applies: https://github.com/fredli74/Typr.ts/blob/master/LICENSE
Expand All @@ -44,6 +93,21 @@ Original licenses apply:
- woff2otf.js: https://github.com/arty-name/woff2otf/blob/master/woff2otf.js (Apache2)
*/

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

/**
* @license
* Copyright 2010-2022 Three.js Authors
Expand Down
2 changes: 0 additions & 2 deletions docs/331.b465e0584817335af634.manager.bundle.js

This file was deleted.

2 changes: 0 additions & 2 deletions docs/331.e13a74bf.iframe.bundle.js

This file was deleted.

Loading

0 comments on commit 2e7921f

Please sign in to comment.