UNPKG

kitchen-simulator

Version:

It is a kitchen simulator (self-contained micro-frontend).

50 lines 1.55 kB
import _typeof from "@babel/runtime/helpers/esm/typeof"; import * as Three from 'three'; String.prototype.isLeftPlaceholder = function () { return this.match(/_L$|_L_\d$/) != null; }; String.prototype.isRightPlaceholder = function () { return this.match(/_R$|_R_\d$/) != null; }; export function objectsMap(object, func) { var mappedObject = {}; for (var key in object) { mappedObject[key] = func(key, mappedObject[key]); } return mappedObject; } export function objectsCompare(x, y) { if (x === y) return true; if (!(x instanceof Object) || !(y instanceof Object)) return false; if (x.constructor !== y.constructor) return false; for (var p in x) { if (!x.hasOwnProperty(p)) continue; if (!y.hasOwnProperty(p)) return false; if (x[p] === y[p]) continue; if (_typeof(x[p]) !== 'object') return false; if (!objectsCompare(x[p], y[p])) return false; } for (var _p in y) { if (y.hasOwnProperty(_p) && !x.hasOwnProperty(_p)) return false; } return true; } export function getAllMeshes(objects) { var meshes = []; objects.forEach(function (object) { if (!object) return; object.traverse(function (o) { if (o.isMesh && o.geometry) { meshes.push(o); } }); }); return meshes; } export function vectorIntersectWithMesh(origin, target) { var vectorDir = new Three.Vector3(origin.x, origin.y - 1000, origin.z); var ray = new Three.Raycaster(); ray.set(origin, vectorDir); var intersects = ray.intersectObject(target, true); return intersects.length > 0; }