New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@qctrl/visualizer

Package Overview
Dependencies
Maintainers
4
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qctrl/visualizer - npm Package Compare versions

Comparing version 2.8.1 to 3.0.0-alpha.0

components/ContentDiv/Content.js

30

components/ToolTip/ToolTip.js

@@ -1,29 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _ToolTipModule = _interopRequireDefault(require("./ToolTip.module.css"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
var ToolTip = (0, _react.memo)(function (_ref) {
var tooltipText = _ref.tooltipText,
isVisible = _ref.isVisible,
position = _ref.position;
return _react.default.createElement("span", {
className: "".concat(_ToolTipModule.default.tooltip, " ").concat(isVisible ? _ToolTipModule.default.visible : _ToolTipModule.default.hidden),
style: {
left: position.left,
top: position.top
}
}, tooltipText);
});
var _default = ToolTip;
exports.default = _default;
"use strict";var _ToolTipModule=_interopRequireDefault(require("./ToolTip.module.css"));Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var ToolTip=document.createElement("span"),_default=function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{top:0,left:0};return ToolTip.innerText=a,ToolTip.className="".concat(_ToolTipModule.default.tooltip," ").concat(b?_ToolTipModule.default.visible:_ToolTipModule.default.hidden),ToolTip.style.left="".concat(c.left,"px"),ToolTip.style.top="".concat(c.top,"px"),ToolTip};exports.default=_default;

@@ -1,35 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function get() {
return _components.default;
}
});
Object.defineProperty(exports, "GRID_TEMPLATE_NAMES", {
enumerable: true,
get: function get() {
return _constants.GRID_TEMPLATE_NAMES;
}
});
Object.defineProperty(exports, "AVAILABLE_THEME_CONTROLS", {
enumerable: true,
get: function get() {
return _constants.AVAILABLE_THEME_CONTROLS;
}
});
Object.defineProperty(exports, "CAMERA_PRESETS", {
enumerable: true,
get: function get() {
return _constants.CAMERA_PRESETS;
}
});
var _components = _interopRequireDefault(require("./components"));
var _constants = require("./utils/constants");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function get(){return _VisualizerEntryPoint.default}}),Object.defineProperty(exports,"AVAILABLE_CONFIGURATIONS",{enumerable:!0,get:function get(){return _constants.AVAILABLE_CONFIGURATIONS}}),Object.defineProperty(exports,"CAMERA_PRESETS",{enumerable:!0,get:function get(){return _constants.CAMERA_PRESETS}}),Object.defineProperty(exports,"AVAILABLE_THEME_CONTROLS",{enumerable:!0,get:function get(){return _themeSettingsControls.AVAILABLE_THEME_CONTROLS}});var _VisualizerEntryPoint=_interopRequireDefault(require("./threeJs/VisualizerEntryPoint")),_constants=require("./utils/constants"),_themeSettingsControls=require("./utils/constants/themeSettingsControls");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}
{
"name": "@qctrl/visualizer",
"version": "2.8.1",
"description": "An animated and interactive quantum state visualisation built with THREE.js and implemented as a React component",
"version": "3.0.0-alpha.0",
"description": "An animated and interactive quantum state visualisation built with THREE.js",
"repository": {

@@ -14,33 +14,33 @@ "type": "git",

"homepage": "https://github.com/qctrl/visualizer#readme",
"peerDependencies": {
"lodash": ">=4.17.11",
"react": ">=16.8.4",
"immutability-helper": ">=3.0.0",
"react-dom": ">=16.8.4",
"prop-types": ">=15.6.1"
"peerDependencies": {},
"scripts": {
"build:dev": "rm -rf dist && babel src --watch --verbose --out-dir dist --copy-files",
"build": "rimraf dist && NODE_ENV=production babel src --out-dir dist --copy-files --ignore __tests__,spec.js,test.js,__snapshots__",
"publishnpm": "yarn && yarn build && cp package.json dist && cp README.md dist && npm publish dist"
},
"main": "index.js",
"license": "UNLICENSED",
"dependencies": {
"three": "^0.103.0",
"color": "^3.1.1",
"immutability-helper": "^3.0.0",
"lodash": "^4.17.11",
"three": "^0.104.0",
"three-orbitcontrols": "^2.102.1"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.4",
"@babel/plugin-proposal-class-properties": "^7.3.4",
"@babel/preset-env": "^7.3.4",
"@babel/preset-react": "^7.0.0",
"rimraf": "^2.6.3"
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.4",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"autoprefixer": "^9.5.1",
"babel-eslint": "^10.0.1",
"babel-preset-minify": "^0.5.0",
"cssnano": "^4.1.10",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.2.0",
"eslint-plugin-prettier": "^3.1.0",
"postcss-modules": "^1.4.1",
"prettier": "^1.17.1"
},
"scripts": {
"build": "rimraf dist && NODE_ENV=production babel lib --out-dir dist --copy-files --ignore __tests__,spec.js,test.js,__snapshots__",
"publishnpm": "yarn && yarn build && cp package.json dist && cp ../README.md dist && rm -r ./node_modules && npm publish dist"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"main": "index.js",
"license": "UNLICENSED"
"browserslist": ">0.2%, not dead, not ie <= 11, not op_mini all"
}

@@ -8,181 +8,8 @@ # Visualizer

1. [Overview](#overview)
2. [Getting started](#getting-started)
3. [Usage](#props)
1. [Props](#props)
2. [Layout Settings](#layout)
4. [Data Format](#data)
5. [Code and Dev Guide](#code-and-development-guide)
6. [Publishing updates to NPM](#publishing-updates-to-npm)
## Overview
* This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).
* Packages are managed with [yarn](https://yarnpkg.com/)
* 3D using [THREE.js](https://threejs.org/), the [npm module version](https://www.npmjs.com/package/three) is being used.
* Camera controls utilising [three-orbit-controls](https://www.npmjs.com/package/three-orbit-controls)
* Code is formatted with [Prettier](https://prettier.io/)
## Getting started
#### Previewing the visualizer as a demo App
* Clone the repo
* On the command line `cd` into the repo and run `yarn`
* Run `yarn start`
* Open [http://localhost:3000/](http://localhost:3000/) in your browser if it
doesn't happen automatically
* Look at the file: `/src/ExampleImplementation.js` for an example of how Bloch Sphere components are implemented in a React App. This example is using dummy data from `/src/twoQubitTestData.js`
* See below for further props and settings to use with the component
#### Adding a Visualizer component to the Q-CTRL App / new React App
* Login to npm from the command line: `npm login` *your npm account must be linked and have access to the qtrl org*
* Install the Visualizer module with `yarn add @qctrl/visualizer`
* Import the Visualizer component to your App `import Visualizer from '@qctrl/visualizer'`
* See below and `/src/ExampleImplementation.js` in the repo for usage guidelines
## Usage: *Props* and *Layout*
#### Props
* The following props can be passed: `onUpdate`, `onError`, `isPlaying`, `progress`, `inputState`, `labels`, `cameraPreset`. Also `layout` and `data` which will be discussed further down.
* #### `onUpdate` should be a function that takes one argument
```javascript
onUpdate={ object => {
this.setState(object);
}}
```
An object containing the state of the visualizer, with the following structure, will be returned:
```json
{progress: 1, currentSegmentNumber: 16, isPlaying: false, isInteracting: true, isHovering: false}
```
* #### `onError` If any errors are thrown within the visualizer component this function will be called (if it has been passed as a prop) with the errors object as the only argument:
```javascript
onError={errors => {
console.log(errors);
}}
```
* #### `inputState` an object with structure
```json
{
qubits: [
{ name: "qubit1", x: 0, y: 1, z: 0 },
{ name: "qubit2", x: 0, y: 0, z: -1 }
],
vectors: [{ name: "a", x: 0, y: 0, z: -1 }]
}
```
that will be set as an arbitrary starting / position for the pulse indicators
* #### `isPlaying` tells the Bloch sphere component to start or stop the animation
* #### `progress` will have the pulse path starting at the progress percent specified. Eg: if you want to have the whole path showing on mount set progress to `1`
```javascript
progress={<float between 0 and 1>}
```
* #### `Labels` needs to be an object with the following structure and will control the visibility of individual labels:
```json
{
xAxis: true,
yAxis: true,
zAxis: true,
theta: true,
thetaArc: true,
phi: true,
phiArc: true,
northPole: true,
southPole: true
}
```
* #### `templateName` tells the visualizer what element layout template to generate, I.e a one qubit layout or a two qubit layout. You can import available templates/names from the library like so:
```javascript
import Visualizer, { GRID_TEMPLATE_NAMES } from "@qctrl/visualizer";
```
#### Layout
* See the file `./src/lib/layout/index.js` to see what structure layout settings need to be in
* If no `layout` prop is passed, all default settings will be used from the layout settings file
* You are able to pass a subset of layout settings for a Bloch Sphere and these will be merged with the rest of the default settings from the settings file, no need to pass all the settings if you only need to customise a few things
#### Some common layout settings explained
* `animation: {fps: 30}` how many times per second the animation loop is called, changes the playback rate, animation will become choppy at lower rates
* `elementTypes`
* `equatorialPlane: {}` is the face of the disc that spans the equator
* `equatorialOutline: {}` is the outline that runs around the surface of the equator
* `axes: {}` controls the guide x, y, z axes
* `pulsePoint: {}` changes the circle at the end of the pulse line. `radius` controls the size, `outlineFactor` controls how much larger than the main circle the outline is
* `pulseArcCurrentSegment: {}` controls the look of the currently animating pulse segment or the segment being hovered over after the animation has completed
* `pulseArc: { geometrySegments: 16 }`, ***needs to be set for larger block spheres for smooth looking points/circles***, default value is 6, this also applies to `pulsePoint: { geometrySegments: 16 }`
## Data
A data object must be passed as a prop called `data`
### Format/structure
#### Structure for 2-qubit-data:
```json
{
"qubits": [
{
"name": "qubit1",
"x": [],
"y": [],
"z": []
},
{
"name": "qubit2",
"x": [],
"y": [],
"z": []
}
],
"vectors": [
{
"name": "a",
"x": [], //xx
"y": [], //yy
"z": [] //zz
},
{
"name": "b",
"x": [], //xy
"y": [], //yz
"z": [] //zx
},
{
"name": "c",
"x": [], //xz
"y": [], //yz
"z": [] //zy
}
],
"segmentIndexes": [],
"entanglementBooleans": [], //array of Booleans
"entanglementMeasures": []
}
```
- See `oneQubitTestData.js` `twoQubitTestData.js` `twoQubitEntanglementTestData.js` for working examples
## Code and Development Guide
* The React component lives in `BlochSphere/index.js`
* It is a React class component with internal state that controls animation and pulse path display
* A `ref` is used to get the div in the render function's reference and pass it to a scene manager so that canvas element that THREE.js will render to can be created
* The file: `/BlochSphere/threejs/scene.js` is imported to the React component file and is used to create a THREE.js `scene`, `renderer`, `camera` and `controls` which ae all returned as an object from the function nd stored as a Class variable in `this.SceneManager` this object now holds references to the above scene objects so they can be called in other places in the component
* The same pattern is used to create and reference objects in the scene such as the sphere and pulse lines
#### Custom Component Methods
* `threeRender()`, `animate()`, `update()` are all required by THREE.js to render an animate a scene
* `animate()` is called recursively via `requestAnimationFrame`
* All calculations for updating the positions and display of Bloch Sphere data is done here
* `componentDidMount()` is used to instantiate all THREE.js objects and add them to the scene / renderer
* `componentDidUpdate()` checks for new props and updates state appropriately, this allows the animation to be started and stopped and the display of the pulse path to be controlled via props
* `componentWillUnmount()` is used to clean up all THREE.js objects, the renderer and the animation loop to free up memory and GPU
* `_handleMouseMove()` is used to calculate mouse over effects for the pulse segments
#### Utils
Contains some specific maths functions for doing various circle / polar geometry stuff as well as some specific THREE.js utils / addons.
## Publishing updates to NPM
* Once you have made and tested your updates you first need to update the version number in `src/package.json`. The best way to do this is to cd into `src` from the command line and run `npm version <update_type>` *update_type* should be `patch`, `minor` or `major`, see [here](https://docs.npmjs.com/getting-started/semantic-versioning) for semantic versioning explanation
* From the `src` directory run `npm run publishnpm` *(`yarn` will not work for this publishing script!)* this will first build/compile using babel then publish the compiled lib to NPM. **Note that you need to be logged in to NPM and your account needs to be linked and have access to the qtrl Org. Also note that using yarn to run the publishnpm script will fail**
* Everything under the `src/lib` folder will be compiled and published
* You may also want to update the version number in the package.json file in the root of the repo to match the `src` package.json file.
- Packages are managed with [yarn](https://yarnpkg.com/)
- 3D using [THREE.js](https://threejs.org/), the [npm module version](https://www.npmjs.com/package/three) is being used.
- Camera controls utilising [three-orbit-controls](https://www.npmjs.com/package/three-orbit-controls)
- Code is formatted with [Prettier](https://prettier.io/)

@@ -1,124 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _three = require("three");
var _elementObjectsManager = _interopRequireDefault(require("./elementObjectsManager"));
var _generateCamera = _interopRequireDefault(require("./generateCamera"));
var _generateControls = _interopRequireDefault(require("./generateControls"));
var _getElementType = _interopRequireDefault(require("./ElementMethods/getElementType"));
var _constants = require("../utils/constants");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var _default =
/*#__PURE__*/
function () {
function _default(div, data, layout, initialFrameIndex, finalFrameIndex, continuousSegments, drawArcs, canvasRect, nonErrorStateData) {
_classCallCheck(this, _default);
this.div = div;
var id = this.div.id;
var segmentIndexes = data.segmentIndexes;
this.scene = new _three.Scene();
this.elementType = (0, _getElementType.default)(id);
this.elementObjects = new _elementObjectsManager.default(data[id], segmentIndexes, initialFrameIndex, finalFrameIndex, layout, this.scene, div, this.elementType, id, continuousSegments, drawArcs, nonErrorStateData[id]);
var CAMERA_PRESETS = _constants.CONSTANTS.CAMERA_PRESETS;
this.CAMERA_PRESETS = CAMERA_PRESETS[this.elementType.toUpperCase()];
this.camera = (0, _generateCamera.default)(canvasRect, div, this.CAMERA_PRESETS, layout.elementTypes[this.elementType].fov);
this.controls = (0, _generateControls.default)(this.camera, this.div, this.elementObjects.polarVectors.origin);
this.mouseSegmentRaycaster = new _three.Raycaster();
this.mouseSegmentRaycaster.linePrecision = layout.pulsePath.lineWidth * 2;
this.labelRaycaster = new _three.Raycaster();
}
_createClass(_default, [{
key: "setCameraPreset",
value: function setCameraPreset(presetName) {
var _this$camera$position;
var PRESET = presetName.toUpperCase();
(_this$camera$position = this.camera.position).set.apply(_this$camera$position, _toConsumableArray(Object.values(this.CAMERA_PRESETS[PRESET] ? this.CAMERA_PRESETS[PRESET] : this.CAMERA_PRESETS.DEFAULT)));
this.controls.update();
}
}, {
key: "threeCleanup",
value: function threeCleanup() {
this.scene.traverse(function (object) {
if (object.isMesh) {
var geometry = object.geometry;
typeof geometry.dispose === "function" && geometry.dispose();
}
typeof object.dispose === "function" && object.dispose();
});
this.scene = undefined;
this.elementObjects = undefined;
this.camera = undefined;
this.controls.dispose();
this.controls = undefined;
this.raycaster = undefined;
}
}, {
key: "update",
value: function update(frameIndex, currentSegmentNumber, updates) {
var elementObjects = this.elementObjects;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = updates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var update = _step.value;
var method = update.method,
_update$args = update.args,
args = _update$args === void 0 ? [] : _update$args;
this[method] && this[method].apply(this, _toConsumableArray(args));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
elementObjects && elementObjects.update(frameIndex, currentSegmentNumber, updates);
}
}]);
return _default;
}();
exports.default = _default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _three=require("three"),_ElementObjectsManager=_interopRequireDefault(require("./ElementObjectsManager")),_generateCamera=_interopRequireDefault(require("./generateCamera")),_generateControls=_interopRequireDefault(require("./generateControls")),_getElementType=_interopRequireDefault(require("./ElementMethods/getElementType")),_constants=require("../utils/constants");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}var _default=/*#__PURE__*/function(){function a(b,c,d,e,f,g,h,i,j){_classCallCheck(this,a),this.div=b;var k=this.div.id,l=c.segmentIndexes;this.scene=new _three.Scene,this.elementType=(0,_getElementType.default)(k),this.elementObjects=new _ElementObjectsManager.default(c[k],l,e,f,d,this.scene,b,this.elementType,k,g,h,j[k]);var m=_constants.CONSTANTS.CAMERA_PRESETS;this.CAMERA_PRESETS=m[this.elementType.toUpperCase()],this.camera=(0,_generateCamera.default)(i,b,this.CAMERA_PRESETS,d.elementTypes[this.elementType].fov),this.controls=(0,_generateControls.default)(this.camera,this.div,this.elementObjects.polarVectors.origin),this.mouseSegmentRaycaster=new _three.Raycaster,this.mouseSegmentRaycaster.linePrecision=2*d.pulsePath.lineWidth,this.labelRaycaster=new _three.Raycaster}return _createClass(a,[{key:"setCameraPreset",value:function setCameraPreset(a){var b,c=a.toUpperCase();(b=this.camera.position).set.apply(b,_toConsumableArray(Object.values(this.CAMERA_PRESETS[c]?this.CAMERA_PRESETS[c]:this.CAMERA_PRESETS.DEFAULT))),this.controls.update()}},{key:"threeCleanup",value:function threeCleanup(){this.scene.traverse(function(a){if(a.isMesh){var b=a.geometry;"function"==typeof b.dispose&&b.dispose()}"function"==typeof a.dispose&&a.dispose()}),this.scene=void 0,this.elementObjects=void 0,this.camera=void 0,this.controls.dispose(),this.controls=void 0,this.raycaster=void 0}},{key:"update",value:function(a,b,c){var d=this.elementObjects,e=!0,f=!1,g=void 0;try{for(var h,i=c[Symbol.iterator]();!(e=(h=i.next()).done);e=!0){var j=h.value,k=j.method,l=j.args,m=void 0===l?[]:l;this[k]&&this[k].apply(this,_toConsumableArray(m))}}catch(a){f=!0,g=a}finally{try{e||null==i.return||i.return()}finally{if(f)throw g}}d&&d.update(a,b,c)}}]),a}();exports.default=_default;

@@ -1,33 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createLineArcVerticesArray = void 0;
var _constants = require("../../utils/constants");
var _three = require("three");
var createLineArcVerticesArray = function createLineArcVerticesArray(pointStart, pointEnd) {
var ARC_SMOOTHNESS = _constants.CONSTANTS.ARC_SMOOTHNESS;
var positions = [];
var cb = new _three.Vector3(),
ab = new _three.Vector3(),
normal = new _three.Vector3();
cb.subVectors(new _three.Vector3(), pointEnd);
ab.subVectors(pointStart, pointEnd);
cb.cross(ab);
normal.copy(cb).normalize();
var angle = pointStart.angleTo(pointEnd);
var angleDelta = angle / (ARC_SMOOTHNESS - 1);
for (var i = 0; i < ARC_SMOOTHNESS; i++) {
var newVector = pointStart.clone().applyAxisAngle(normal, angleDelta * i);
positions.push(newVector.x, newVector.y, newVector.z);
}
return positions;
};
exports.createLineArcVerticesArray = createLineArcVerticesArray;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createLineArcVerticesArray=void 0;var _constants=require("../../utils/constants"),_three=require("three"),createLineArcVerticesArray=function(a,b){var c=_constants.CONSTANTS.ARC_SMOOTHNESS,d=[],e=new _three.Vector3,f=new _three.Vector3,g=new _three.Vector3;e.subVectors(new _three.Vector3,b),f.subVectors(a,b),e.cross(f),g.copy(e).normalize();for(var h,j=a.angleTo(b),k=0;k<c;k++)h=a.clone().applyAxisAngle(g,j/(c-1)*k),d.push(h.x,h.y,h.z);return d};exports.createLineArcVerticesArray=createLineArcVerticesArray;

@@ -1,19 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _constants = require("../../utils/constants");
var _default = function _default(elementId) {
var ELEMENT_TYPES = _constants.CONSTANTS.ELEMENT_TYPES,
ELEMENT_REGEX_STRINGS = _constants.CONSTANTS.ELEMENT_REGEX_STRINGS;
var TETRAHEDRON = ELEMENT_TYPES.TETRAHEDRON,
BLOCHSPHERE = ELEMENT_TYPES.BLOCHSPHERE;
var blochSphereRegEx = new RegExp(ELEMENT_REGEX_STRINGS.BLOCHSPHERE.join("|"), "i");
return blochSphereRegEx.test(elementId) ? BLOCHSPHERE : TETRAHEDRON;
};
exports.default = _default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _constants=require("../../utils/constants"),_default=function(a){var b=_constants.CONSTANTS.ELEMENT_TYPES,c=_constants.CONSTANTS.ELEMENT_REGEX_STRINGS,d=b.TETRAHEDRON,e=b.BLOCHSPHERE,f=new RegExp(c.BLOCHSPHERE.join("|"),"i");return f.test(a)?e:d};exports.default=_default;

@@ -1,46 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _three = require("three");
var _lodash = _interopRequireDefault(require("lodash"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = function _default(segmentGroupOrLineMesh, _ref) {
var _ref$opacity = _ref.opacity,
newOpacity = _ref$opacity === void 0 ? null : _ref$opacity,
newColor = _ref.color,
newLineWidth = _ref.lineWidth;
segmentGroupOrLineMesh.traverse(function (child) {
var material = child.material;
if (material) {
var color = material.color,
linewidth = material.linewidth,
side = material.side;
var newSide = newOpacity ? _three.DoubleSide : _three.BackSide;
if (!child.userData.noDraw && newSide !== side && newOpacity !== null) {
material.side = newSide;
}
var currentLineWidth = linewidth,
currentColor = color;
if (newLineWidth && newLineWidth !== currentLineWidth) {
material.linewidth = newLineWidth;
}
if (newColor && !_lodash.default.isEqual(newColor, currentColor)) {
material.color = newColor;
}
}
});
};
exports.default = _default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _three=require("three"),_lodash=_interopRequireDefault(require("lodash"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var _default=function(a,b){var c=b.opacity,d=void 0===c?null:c,e=b.color,f=b.lineWidth;a.traverse(function(a){var b=a.material;if(b){var c=b.color,g=b.linewidth,h=b.side,i=d?_three.DoubleSide:_three.BackSide;a.userData.noDraw||i===h||null===d||(b.side=i);f&&f!==g&&(b.linewidth=f),e&&!_lodash.default.isEqual(e,c)&&(b.color=e)}})};exports.default=_default;

@@ -1,35 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _three = require("three");
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var _default = function _default(canvasRect, div, cameraPresets, fov) {
var _camera$position;
var divRect = div.getBoundingClientRect();
var width = divRect.width,
height = divRect.height;
var defaultCameraPosition = cameraPresets.DEFAULT;
var aspect = width / height;
var camera = new _three.PerspectiveCamera(fov, aspect, 0.1, 100);
(_camera$position = camera.position).set.apply(_camera$position, _toConsumableArray(Object.values(defaultCameraPosition)));
camera.up.set(0, 0, 1);
camera.updateProjectionMatrix();
return camera;
};
exports.default = _default;
"use strict";var _three=require("three");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}}var _default=function(a,b,c,d){var e,f=b.getBoundingClientRect(),g=f.width,h=f.height,i=c.DEFAULT,j=new _three.PerspectiveCamera(d,g/h,.1,100);return(e=j.position).set.apply(e,_toConsumableArray(Object.values(i))),j.up.set(0,0,1),j.updateProjectionMatrix(),j};exports.default=_default;

@@ -1,22 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _threeOrbitcontrols = _interopRequireDefault(require("three-orbitcontrols"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = function _default(camera, element, origin) {
var controls = new _threeOrbitcontrols.default(camera, element);
controls.target = origin;
controls.enablePan = false;
controls.enableZoom = false;
controls.enableKeys = false;
controls.update();
return controls;
};
exports.default = _default;
"use strict";var _threeOrbitcontrols=_interopRequireDefault(require("three-orbitcontrols"));Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var _default=function(a,b,c){var d=new _threeOrbitcontrols.default(a,b);return d.target=c,d.enablePan=!1,d.enableZoom=!1,d.enableKeys=!1,d.update(),d};exports.default=_default;

@@ -1,24 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _three = require("three");
var _default = function _default(canvas, rect) {
var renderer = new _three.WebGLRenderer({
canvas: canvas,
powerPreference: "low-power",
antialias: true
});
var width = rect.width,
height = rect.height;
var DPR = window.devicePixelRatio ? window.devicePixelRatio : 1;
renderer.setPixelRatio(DPR);
renderer.setSize(width, height);
return renderer;
};
exports.default = _default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _three=require("three"),_default=function(a,b){var c=new _three.WebGLRenderer({canvas:a,powerPreference:"low-power",antialias:!0}),d=b.width,e=b.height,f=window.devicePixelRatio?window.devicePixelRatio:1;return c.setPixelRatio(f),c.setSize(d,e),c};exports.default=_default;

@@ -1,72 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _three = require("three");
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var _default = function _default(originVector, _ref, _ref2, radius, radialOffset, origin) {
var _axes$position;
var equatorEastAxis = _ref.equatorEastAxis,
northPoleAxis = _ref.northPoleAxis,
equatorSouthOneAxis = _ref.equatorSouthOneAxis;
var color = _ref2.color,
cylinderRadius = _ref2.cylinderRadius,
arrowRadius = _ref2.arrowRadius,
arrowHeight = _ref2.arrowHeight,
axesSegments = _ref2.axesSegments;
//Axes Material
var arrowMaterial = new _three.MeshBasicMaterial({
color: color,
polygonOffset: true,
polygonOffsetUnits: 1,
polygonOffsetFactor: -50
});
var axesMaterial = new _three.MeshBasicMaterial({
color: color
});
radius = radius * radialOffset;
var axesxGeometry = new _three.CylinderBufferGeometry(cylinderRadius, cylinderRadius, radius, axesSegments, axesSegments);
var arrowGeometry = new _three.ConeBufferGeometry(arrowRadius, arrowHeight, axesSegments, axesSegments); // X Axis
var xAxis = new _three.Mesh(axesxGeometry, axesMaterial);
xAxis.position.set(0, 0, radius / 2);
xAxis.quaternion.setFromAxisAngle(new _three.Vector3(0, 1, 1).normalize(), Math.PI); // X arrow
var xArrow = new _three.Mesh(arrowGeometry, arrowMaterial);
xArrow.position.set(equatorSouthOneAxis.x, equatorSouthOneAxis.y, equatorSouthOneAxis.z);
xArrow.quaternion.setFromAxisAngle(new _three.Vector3(1, 1, 0).normalize(), Math.PI); // Y Axis
var yAxis = new _three.Mesh(axesxGeometry, axesMaterial);
yAxis.position.set(0, radius / 2, 0); // Y arrow
var yArrow = new _three.Mesh(arrowGeometry, arrowMaterial);
yArrow.position.set(equatorEastAxis.x, equatorEastAxis.y, equatorEastAxis.z); // Z Axis
var zAxis = new _three.Mesh(axesxGeometry, axesMaterial);
zAxis.position.set(radius / 2, 0, 0);
zAxis.quaternion.setFromAxisAngle(new _three.Vector3(1, 1, 0).normalize(), Math.PI); // Z arrow
var zArrow = new _three.Mesh(arrowGeometry, arrowMaterial);
zArrow.position.set(northPoleAxis.x, northPoleAxis.y, northPoleAxis.z);
zArrow.quaternion.setFromAxisAngle(new _three.Vector3(0, 1, 1).normalize(), Math.PI);
var axes = new _three.Group();
axes.add(xAxis, xArrow, yAxis, yArrow, zAxis, zArrow);
(_axes$position = axes.position).set.apply(_axes$position, _toConsumableArray(Object.values(origin)));
return axes;
};
exports.default = _default;
"use strict";var _three=require("three");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}}var _default=function(a,b,c,d,e,f){var g,h=b.equatorEastAxis,i=b.northPoleAxis,j=b.equatorSouthOneAxis,k=c.color,l=c.cylinderRadius,m=c.arrowRadius,n=c.arrowHeight,o=c.axesSegments,p=new _three.MeshBasicMaterial({color:k,polygonOffset:!0,polygonOffsetUnits:1,polygonOffsetFactor:-50}),q=new _three.MeshBasicMaterial({color:k});d*=e;var r=new _three.CylinderBufferGeometry(l,l,d,o,o),s=new _three.ConeBufferGeometry(m,n,o,o),t=new _three.Mesh(r,q);t.position.set(0,0,d/2),t.quaternion.setFromAxisAngle(new _three.Vector3(0,1,1).normalize(),Math.PI);// X arrow
var u=new _three.Mesh(s,p);u.position.set(j.x,j.y,j.z),u.quaternion.setFromAxisAngle(new _three.Vector3(1,1,0).normalize(),Math.PI);// Y Axis
var v=new _three.Mesh(r,q);v.position.set(0,d/2,0);// Y arrow
var w=new _three.Mesh(s,p);w.position.set(h.x,h.y,h.z);// Z Axis
var x=new _three.Mesh(r,q);x.position.set(d/2,0,0),x.quaternion.setFromAxisAngle(new _three.Vector3(1,1,0).normalize(),Math.PI);// Z arrow
var y=new _three.Mesh(s,p);y.position.set(i.x,i.y,i.z),y.quaternion.setFromAxisAngle(new _three.Vector3(0,1,1).normalize(),Math.PI);var z=new _three.Group;return z.add(t,u,v,w,x,y),(g=z.position).set.apply(g,_toConsumableArray(Object.values(f))),z};exports.default=_default;

@@ -1,69 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createCircleMaterial = exports.default = void 0;
var _three = require("three");
var _constants = require("../../utils/constants");
var _default = function _default(_ref, _ref2, material, sphereRadius, name) {
var segments = _ref.segments,
radius = _ref.radius,
labelOffset = _ref.labelOffset;
var x = _ref2.x,
y = _ref2.y,
z = _ref2.z;
//
var _CONSTANTS$NAMES$LABE = _constants.CONSTANTS.NAMES.LABELS,
PHI_ARC = _CONSTANTS$NAMES$LABE.PHI_ARC,
THETA_ARC = _CONSTANTS$NAMES$LABE.THETA_ARC;
var thetaEndPhi = (Math.atan2(y, x) + 2 * Math.PI) % (2 * Math.PI);
var pZero = Math.max(Math.min(1, (1 + z / sphereRadius) / 2), 0);
var thetaEndTheta = 2 * Math.acos(Math.sqrt(pZero));
var circleGeometry, labelArcGeometry;
if (name === PHI_ARC) {
circleGeometry = new _three.CircleGeometry(radius, segments, 0, thetaEndPhi);
labelArcGeometry = new _three.CircleGeometry(radius + labelOffset, segments, 0, thetaEndPhi);
} else if (name === THETA_ARC) {
circleGeometry = new _three.CircleGeometry(radius, segments, 0, thetaEndTheta);
labelArcGeometry = new _three.CircleGeometry(radius + labelOffset, segments, 0, thetaEndTheta);
circleGeometry.rotateY(-Math.PI / 2);
circleGeometry.rotateZ(-Math.PI / 2 + thetaEndPhi);
labelArcGeometry.rotateY(-Math.PI / 2);
labelArcGeometry.rotateZ(-Math.PI / 2 + thetaEndPhi);
} // if the current vector/state is {x:0 ,y:0, z:+1 } there will be no arc for theta, in this case null will be returned from this function and nothing will be added to the scene in the main index.js
var arc = circleGeometry.faces.length > 0 ? new _three.Mesh(circleGeometry, material) : null;
if (arc) {
arc.name = name;
}
return {
arc: arc,
labelArcGeometry: labelArcGeometry
};
};
exports.default = _default;
var createCircleMaterial = function createCircleMaterial(_ref3, name) {
var phiColor = _ref3.phiColor,
thetaColor = _ref3.thetaColor;
return new _three.MeshBasicMaterial({
color: name === "phi" ? phiColor : thetaColor,
transparent: true,
opacity: 1,
depthWrite: false,
depthTest: false,
side: _three.DoubleSide,
name: name
});
};
exports.createCircleMaterial = createCircleMaterial;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createCircleMaterial=exports.default=void 0;var _three=require("three"),_constants=require("../../utils/constants"),_default=function(a,b,c,d,e){var f,g,h=a.segments,i=a.radius,j=a.labelOffset,k=b.x,l=b.y,m=b.z,n=_constants.CONSTANTS.NAMES.LABELS,o=n.PHI_ARC,p=n.THETA_ARC,q=(Math.atan2(l,k)+2*Math.PI)%(2*Math.PI),r=Math.max(Math.min(1,(1+m/d)/2),0),s=2*Math.acos(Math.sqrt(r));e===o?(f=new _three.CircleGeometry(i,h,0,q),g=new _three.CircleGeometry(i+j,h,0,q)):e===p&&(f=new _three.CircleGeometry(i,h,0,s),g=new _three.CircleGeometry(i+j,h,0,s),f.rotateY(-Math.PI/2),f.rotateZ(-Math.PI/2+q),g.rotateY(-Math.PI/2),g.rotateZ(-Math.PI/2+q));// if the current vector/state is {x:0 ,y:0, z:+1 } there will be no arc for theta, in this case null will be returned from this function and nothing will be added to the scene in the main index.js
var t=0<f.faces.length?new _three.Mesh(f,c):null;return t&&(t.name=e),{arc:t,labelArcGeometry:g}};exports.default=_default;var createCircleMaterial=function(a,b){var c=a.phiColor,d=a.thetaColor;return new _three.MeshBasicMaterial({color:"phi"===b?c:d,transparent:!0,opacity:1,depthWrite:!1,depthTest:!1,side:_three.DoubleSide,name:b})};exports.createCircleMaterial=createCircleMaterial;

@@ -1,65 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.generateDecoherenceLine = void 0;
var _three = require("three");
var _Line = require("../../utils/threejs/Line");
var _createLineArcVerticesArray = require("../ElementMethods/createLineArcVerticesArray");
var _constants = require("../../utils/constants");
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var generateDecoherenceLine = function () {
var material;
return function (currentPulseVector, currentNonErrorStateVector, _ref, _ref2, elementType) {
var color = _ref.color,
lineWidth = _ref.lineWidth,
dashSize = _ref.dashSize,
gapSize = _ref.gapSize;
var width = _ref2.width,
height = _ref2.height;
if (!material) {
material = new _Line.LineMaterial({
color: color,
linewidth: lineWidth,
polygonOffset: true,
polygonOffsetFactor: -100,
dashed: true,
dashSize: dashSize,
gapSize: gapSize
});
}
material.defines.USE_DASH = "";
material.needsUpdate = true;
var geometry = new _Line.LineGeometry();
var x = currentNonErrorStateVector.x,
y = currentNonErrorStateVector.y,
z = currentNonErrorStateVector.z;
var linePositions = elementType === _constants.CONSTANTS.ELEMENT_TYPES.BLOCHSPHERE ? (0, _createLineArcVerticesArray.createLineArcVerticesArray)(currentPulseVector, new _three.Vector3(x, y, z)) : [].concat(_toConsumableArray(Object.values(currentPulseVector)), [x, y, z]);
geometry.setPositions(linePositions);
var decoherence = new _Line.Line(geometry, material);
decoherence.material.resolution.set(width, height);
material.userData.themeControls = [_constants.THEME_SETTING_CONTROLS.HIGHLIGHT_COLOR];
geometry.dispose();
return {
line: decoherence,
material: material
};
};
}();
exports.generateDecoherenceLine = generateDecoherenceLine;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.generateDecoherenceLine=void 0;var _three=require("three"),_Line=require("../../utils/threejs/Line"),_createLineArcVerticesArray=require("../ElementMethods/createLineArcVerticesArray"),_constants=require("../../utils/constants"),_themeSettingsControls=require("../../utils/constants/themeSettingsControls");function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}}var generateDecoherenceLine=function(){var a;return function(b,c,d,e,f){var g=d.color,h=d.lineWidth,i=d.dashSize,j=d.gapSize,k=e.width,l=e.height;a||(a=new _Line.LineMaterial({color:g,linewidth:h,polygonOffset:!0,polygonOffsetFactor:-100,dashed:!0,dashSize:i,gapSize:j})),a.defines.USE_DASH="",a.needsUpdate=!0;var m=new _Line.LineGeometry,n=c.x,o=c.y,p=c.z,q=f===_constants.CONSTANTS.ELEMENT_TYPES.BLOCHSPHERE?(0,_createLineArcVerticesArray.createLineArcVerticesArray)(b,new _three.Vector3(n,o,p)):[].concat(_toConsumableArray(Object.values(b)),[n,o,p]);m.setPositions(q);var r=new _Line.Line(m,a);return r.material.resolution.set(k,l),a.userData.themeControls=[_themeSettingsControls.THEME_SETTING_CONTROLS.HIGHLIGHT_COLOR],m.dispose(),{line:r,material:a}}}();exports.generateDecoherenceLine=generateDecoherenceLine;

@@ -1,55 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _three = require("three");
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
// Outline
var _default = function _default(_ref, radius, origin) {
var _equatorialPlane$posi;
var outline = _ref.outline,
color = _ref.color,
opacity = _ref.opacity,
segments = _ref.segments;
// Plane
var circleGeometry = new _three.CircleBufferGeometry(radius, segments);
var outlineGeometry = new _three.RingBufferGeometry(radius, radius + outline.lineWidth, outline.segments, outline.segments);
var circleMaterial = new _three.MeshLambertMaterial({
color: color,
transparent: true,
opacity: opacity,
depthWrite: false,
// allows lines to be seen through circle mesh
side: _three.DoubleSide
});
var outlineMaterial = new _three.MeshStandardMaterial({
color: outline.color,
transparent: true,
opacity: outline.opacity,
side: _three.DoubleSide,
polygonOffset: true,
polygonOffsetFactor: -100
});
var circleMesh = new _three.Mesh(circleGeometry, circleMaterial);
var outlineMesh = new _three.Mesh(outlineGeometry, outlineMaterial);
var equatorialPlane = new _three.Group();
equatorialPlane.add(circleMesh, outlineMesh);
(_equatorialPlane$posi = equatorialPlane.position).set.apply(_equatorialPlane$posi, _toConsumableArray(Object.values(origin)));
return equatorialPlane;
};
exports.default = _default;
"use strict";var _three=require("three");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}}// Outline
var _default=function(a,b,c){var d,e=a.outline,f=a.color,g=a.opacity,h=a.segments,i=new _three.CircleBufferGeometry(b,h),j=new _three.RingBufferGeometry(b,b+e.lineWidth,e.segments,e.segments),k=new _three.MeshLambertMaterial({color:f,transparent:!0,opacity:g,depthWrite:!1,// allows lines to be seen through circle mesh
side:_three.DoubleSide}),l=new _three.MeshStandardMaterial({color:e.color,transparent:!0,opacity:e.opacity,side:_three.DoubleSide,polygonOffset:!0,polygonOffsetFactor:-100}),m=new _three.Mesh(i,k),n=new _three.Mesh(j,l),o=new _three.Group;return o.add(m,n),(d=o.position).set.apply(d,_toConsumableArray(Object.values(c))),o};exports.default=_default;

@@ -1,85 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Axes", {
enumerable: true,
get: function get() {
return _axes.default;
}
});
Object.defineProperty(exports, "CoordinateArc", {
enumerable: true,
get: function get() {
return _coordinateArc.default;
}
});
Object.defineProperty(exports, "createCircleMaterial", {
enumerable: true,
get: function get() {
return _coordinateArc.createCircleMaterial;
}
});
Object.defineProperty(exports, "EquatorialPlane", {
enumerable: true,
get: function get() {
return _equatorialPlane.default;
}
});
Object.defineProperty(exports, "PulsePath", {
enumerable: true,
get: function get() {
return _pulsePath.default;
}
});
Object.defineProperty(exports, "PulseIndicator", {
enumerable: true,
get: function get() {
return _pulseIndicator.default;
}
});
Object.defineProperty(exports, "Shape", {
enumerable: true,
get: function get() {
return _shape.default;
}
});
Object.defineProperty(exports, "Tetrahedron", {
enumerable: true,
get: function get() {
return _shape.default;
}
});
Object.defineProperty(exports, "Lights", {
enumerable: true,
get: function get() {
return _lights.default;
}
});
Object.defineProperty(exports, "Labels", {
enumerable: true,
get: function get() {
return _labels.default;
}
});
var _axes = _interopRequireDefault(require("./axes"));
var _coordinateArc = _interopRequireWildcard(require("./coordinateArc"));
var _equatorialPlane = _interopRequireDefault(require("./equatorialPlane"));
var _pulsePath = _interopRequireDefault(require("./pulsePath"));
var _pulseIndicator = _interopRequireDefault(require("./pulseIndicator"));
var _shape = _interopRequireDefault(require("./shape"));
var _lights = _interopRequireDefault(require("./lights"));
var _labels = _interopRequireDefault(require("./labels"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Axes",{enumerable:!0,get:function get(){return _axes.default}}),Object.defineProperty(exports,"CoordinateArc",{enumerable:!0,get:function get(){return _coordinateArc.default}}),Object.defineProperty(exports,"createCircleMaterial",{enumerable:!0,get:function get(){return _coordinateArc.createCircleMaterial}}),Object.defineProperty(exports,"EquatorialPlane",{enumerable:!0,get:function get(){return _equatorialPlane.default}}),Object.defineProperty(exports,"PulsePath",{enumerable:!0,get:function get(){return _pulsePath.default}}),Object.defineProperty(exports,"PulseIndicator",{enumerable:!0,get:function get(){return _pulseIndicator.default}}),Object.defineProperty(exports,"Shape",{enumerable:!0,get:function get(){return _shape.default}}),Object.defineProperty(exports,"Tetrahedron",{enumerable:!0,get:function get(){return _shape.default}}),Object.defineProperty(exports,"Lights",{enumerable:!0,get:function get(){return _lights.default}}),Object.defineProperty(exports,"Labels",{enumerable:!0,get:function get(){return _labels.default}});var _axes=_interopRequireDefault(require("./axes")),_coordinateArc=_interopRequireWildcard(require("./coordinateArc")),_equatorialPlane=_interopRequireDefault(require("./equatorialPlane")),_pulsePath=_interopRequireDefault(require("./pulsePath")),_pulseIndicator=_interopRequireDefault(require("./pulseIndicator")),_shape=_interopRequireDefault(require("./shape")),_lights=_interopRequireDefault(require("./lights")),_labels=_interopRequireDefault(require("./labels"));function _interopRequireWildcard(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)if(Object.prototype.hasOwnProperty.call(a,c)){var d=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(a,c):{};d.get||d.set?Object.defineProperty(b,c,d):b[c]=a[c]}return b.default=a,b}function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}

@@ -1,169 +0,15 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _three = require("three");
var _x = _interopRequireDefault(require("../../assets/labels/blochSphere/axes/x.svg"));
var _y = _interopRequireDefault(require("../../assets/labels/blochSphere/axes/y.svg"));
var _z = _interopRequireDefault(require("../../assets/labels/blochSphere/axes/z.svg"));
var _zero = _interopRequireDefault(require("../../assets/labels/blochSphere/states/zero.svg"));
var _one = _interopRequireDefault(require("../../assets/labels/blochSphere/states/one.svg"));
var _theta = _interopRequireDefault(require("../../assets/labels/blochSphere/coordinates/theta.svg"));
var _phi = _interopRequireDefault(require("../../assets/labels/blochSphere/coordinates/phi.svg"));
var _XX = _interopRequireDefault(require("../../assets/labels/tetrahedron/XX.svg"));
var _YY = _interopRequireDefault(require("../../assets/labels/tetrahedron/YY.svg"));
var _ZZ = _interopRequireDefault(require("../../assets/labels/tetrahedron/ZZ.svg"));
var _XY = _interopRequireDefault(require("../../assets/labels/tetrahedron/XY.svg"));
var _XZ = _interopRequireDefault(require("../../assets/labels/tetrahedron/XZ.svg"));
var _YX = _interopRequireDefault(require("../../assets/labels/tetrahedron/YX.svg"));
var _ZX = _interopRequireDefault(require("../../assets/labels/tetrahedron/ZX.svg"));
var _ZY = _interopRequireDefault(require("../../assets/labels/tetrahedron/ZY.svg"));
var _YZ = _interopRequireDefault(require("../../assets/labels/tetrahedron/YZ.svg"));
var _nonErrorStateDot = _interopRequireDefault(require("../../assets/labels/non-error-state-dot.svg"));
var _constants = require("../../utils/constants");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var createSprite = function createSprite(svg, color, scale, x, y, z) {
var origin = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {
x: 0,
y: 0,
z: 0
};
var spriteMap = new _three.TextureLoader().load(svg);
var spriteMaterial = new _three.SpriteMaterial({
map: spriteMap,
color: color,
depthTest: false,
transparent: true,
opacity: 1
});
var sprite = new _three.Sprite(spriteMaterial);
sprite.scale.set(scale, scale, scale);
var ox = origin.x,
oy = origin.y,
oz = origin.z;
sprite.position.set(x + ox, y + oy, z + oz);
return sprite;
};
var _default = function _default(_ref, _ref2, elementType, elementId, pulsePoint, nonErrorStateDot) {
var equatorEastAxis = _ref.equatorEastAxis,
northPoleAxis = _ref.northPoleAxis,
southPoleAxis = _ref.southPoleAxis,
equatorSouthOneAxis = _ref.equatorSouthOneAxis,
origin = _ref.origin;
var color = _ref2.color,
scale = _ref2.scale,
offset = _ref2.offset,
nonErrorStateDotScale = _ref2.nonErrorStateDotScale,
pulseIndicatorScale = _ref2.pulseIndicatorScale;
var ELEMENT_TYPES = _constants.CONSTANTS.ELEMENT_TYPES,
ELEMENT_IDS = _constants.CONSTANTS.ELEMENT_IDS;
var BLOCHSPHERE = ELEMENT_TYPES.BLOCHSPHERE,
TETRAHEDRON = ELEMENT_TYPES.TETRAHEDRON;
var A = ELEMENT_IDS.A,
B = ELEMENT_IDS.B,
C = ELEMENT_IDS.C;
var labels = new _three.Group();
var xSVG, ySVG, zSVG;
if (elementType === BLOCHSPHERE) {
// coordinate labels
//// theta
var thetaLabel = createSprite(_theta.default, color, scale, origin.x, origin.y + offset, origin.z + offset);
thetaLabel.name = _constants.CONSTANTS.NAMES.LABELS.THETA; //// phi
var phiLabel = createSprite(_phi.default, color, scale, origin.x + offset, origin.y + offset, origin.z);
phiLabel.name = _constants.CONSTANTS.NAMES.LABELS.PHI; // state labels
//// 0
var zeroLabel = createSprite(_zero.default, color, scale, northPoleAxis.x + offset, northPoleAxis.y, northPoleAxis.z + offset / 2);
zeroLabel.center = new _three.Vector2(0.5, 0.2);
zeroLabel.name = "northPole"; //// 1
var oneLabel = createSprite(_one.default, color, scale, southPoleAxis.x, southPoleAxis.y, southPoleAxis.z - offset);
oneLabel.name = "southPole";
labels.add(zeroLabel, oneLabel, thetaLabel, phiLabel);
xSVG = _x.default;
ySVG = _y.default;
zSVG = _z.default;
} else if (elementType === TETRAHEDRON) {
switch (elementId) {
case A:
xSVG = _XY.default;
ySVG = _YZ.default;
zSVG = _ZX.default;
break;
case B:
xSVG = _XZ.default;
ySVG = _YX.default;
zSVG = _ZY.default;
break;
case C:
xSVG = _XX.default;
ySVG = _YY.default;
zSVG = _ZZ.default;
break;
default:
break;
}
} // Axes Labels
//// X label
var xLabel = createSprite(xSVG, color, scale, equatorSouthOneAxis.x + offset, equatorSouthOneAxis.y, equatorSouthOneAxis.z, origin);
xLabel.name = "xAxis"; //// Y label
var yLabel = createSprite(ySVG, color, scale, equatorEastAxis.x, equatorEastAxis.y + offset, equatorEastAxis.z, origin);
yLabel.name = "yAxis"; //// z label
var zLabel = createSprite(zSVG, color, scale, northPoleAxis.x, northPoleAxis.y, northPoleAxis.z + offset / 2, origin);
zLabel.name = "zAxis";
labels.add(xLabel, yLabel, zLabel); //// Indicator Dots
//non error state dot
var nonErrorStateLabel = createSprite(_nonErrorStateDot.default, nonErrorStateDot.color, nonErrorStateDotScale || scale, 0, 0, 1, origin);
nonErrorStateLabel.name = _constants.CONSTANTS.NAMES.LABELS.NON_ERROR_STATE;
nonErrorStateLabel.userData.themeControls = [_constants.THEME_SETTING_CONTROLS.NON_ERROR_STATE_DOT_COLOR];
nonErrorStateLabel.userData.isIndicator = true;
labels.add(nonErrorStateLabel); // Pulse Indicator
var pulsePointDot = createSprite(_nonErrorStateDot.default, pulsePoint.color, pulseIndicatorScale || scale, 0, 0, 1, origin);
pulsePointDot.name = _constants.CONSTANTS.NAMES.LABELS.PULSE_INDICATOR;
pulsePointDot.userData.themeControls = [_constants.THEME_SETTING_CONTROLS.INDICATOR_COLOR];
pulsePointDot.userData.isIndicator = true;
labels.add(pulsePointDot); //TODO: Find a better way to expose nested objects that are themeable?
return {
labelsGroup: labels,
nonErrorStateLabel: nonErrorStateLabel,
pulsePointDot: pulsePointDot
};
};
exports.default = _default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _three=require("three"),_x=_interopRequireDefault(require("../../assets/labels/blochSphere/axes/x.svg")),_y=_interopRequireDefault(require("../../assets/labels/blochSphere/axes/y.svg")),_z=_interopRequireDefault(require("../../assets/labels/blochSphere/axes/z.svg")),_zero=_interopRequireDefault(require("../../assets/labels/blochSphere/states/zero.svg")),_one=_interopRequireDefault(require("../../assets/labels/blochSphere/states/one.svg")),_theta=_interopRequireDefault(require("../../assets/labels/blochSphere/coordinates/theta.svg")),_phi=_interopRequireDefault(require("../../assets/labels/blochSphere/coordinates/phi.svg")),_XX=_interopRequireDefault(require("../../assets/labels/tetrahedron/XX.svg")),_YY=_interopRequireDefault(require("../../assets/labels/tetrahedron/YY.svg")),_ZZ=_interopRequireDefault(require("../../assets/labels/tetrahedron/ZZ.svg")),_XY=_interopRequireDefault(require("../../assets/labels/tetrahedron/XY.svg")),_XZ=_interopRequireDefault(require("../../assets/labels/tetrahedron/XZ.svg")),_YX=_interopRequireDefault(require("../../assets/labels/tetrahedron/YX.svg")),_ZX=_interopRequireDefault(require("../../assets/labels/tetrahedron/ZX.svg")),_ZY=_interopRequireDefault(require("../../assets/labels/tetrahedron/ZY.svg")),_YZ=_interopRequireDefault(require("../../assets/labels/tetrahedron/YZ.svg")),_nonErrorStateDot=_interopRequireDefault(require("../../assets/labels/non-error-state-dot.svg")),_constants=require("../../utils/constants"),_themeSettingsControls=require("../../utils/constants/themeSettingsControls");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var createSprite=function(a,b,c,d,e,f){var g=6<arguments.length&&void 0!==arguments[6]?arguments[6]:{x:0,y:0,z:0},h=new _three.TextureLoader().load(a),i=new _three.SpriteMaterial({map:h,color:b,depthTest:!1,transparent:!0,opacity:1}),j=new _three.Sprite(i);j.scale.set(c,c,c);var k=g.x,l=g.y,m=g.z;return j.position.set(d+k,e+l,f+m),j},_default=function(a,b,c,d,e,f){var g,h,i,j=a.equatorEastAxis,k=a.northPoleAxis,l=a.southPoleAxis,m=a.equatorSouthOneAxis,n=a.origin,o=b.color,p=b.scale,q=b.offset,r=b.nonErrorStateDotScale,s=b.pulseIndicatorScale,t=_constants.CONSTANTS.ELEMENT_TYPES,u=_constants.CONSTANTS.ELEMENT_IDS,v=t.BLOCHSPHERE,w=t.TETRAHEDRON,x=u.A,y=u.B,z=u.C,A=new _three.Group;if(c===v){// coordinate labels
//// theta
var G=createSprite(_theta.default,o,p,n.x,n.y+q,n.z+q);G.name=_constants.CONSTANTS.NAMES.LABELS.THETA;//// phi
var H=createSprite(_phi.default,o,p,n.x+q,n.y+q,n.z);H.name=_constants.CONSTANTS.NAMES.LABELS.PHI;// state labels
//// 0
var I=createSprite(_zero.default,o,p,k.x+q,k.y,k.z+q/2);I.center=new _three.Vector2(.5,.2),I.name="northPole";//// 1
var J=createSprite(_one.default,o,p,l.x,l.y,l.z-q);J.name="southPole",A.add(I,J,G,H),g=_x.default,h=_y.default,i=_z.default}else if(c===w)switch(d){case x:g=_XY.default,h=_YZ.default,i=_ZX.default;break;case y:g=_XZ.default,h=_YX.default,i=_ZY.default;break;case z:g=_XX.default,h=_YY.default,i=_ZZ.default;break;default:}// Axes Labels
//// X label
var B=createSprite(g,o,p,m.x+q,m.y,m.z,n);B.name="xAxis";//// Y label
var C=createSprite(h,o,p,j.x,j.y+q,j.z,n);C.name="yAxis";//// z label
var D=createSprite(i,o,p,k.x,k.y,k.z+q/2,n);D.name="zAxis",A.add(B,C,D);//// Indicator Dots
//non error state dot
var E=createSprite(_nonErrorStateDot.default,f.color,r||p,0,0,1,n);E.name=_constants.CONSTANTS.NAMES.LABELS.NON_ERROR_STATE,E.userData.themeControls=[_themeSettingsControls.THEME_SETTING_CONTROLS.NON_ERROR_STATE_DOT_COLOR],E.userData.isIndicator=!0,A.add(E);// Pulse Indicator
var F=createSprite(_nonErrorStateDot.default,e.color,s||p,0,0,1,n);//TODO: Find a better way to expose nested objects that are themeable?
return F.name=_constants.CONSTANTS.NAMES.LABELS.PULSE_INDICATOR,F.userData.themeControls=[_themeSettingsControls.THEME_SETTING_CONTROLS.INDICATOR_COLOR],F.userData.isIndicator=!0,A.add(F),{labelsGroup:A,nonErrorStateLabel:E,pulsePointDot:F}};exports.default=_default;

@@ -1,46 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _three = require("three");
var _constants = require("../../utils/constants");
var _default = function _default(radius, _ref, origin, elementType) {
var ambientColor = _ref.ambientColor,
ambientLightIntensity = _ref.ambientLightIntensity,
pointLightIntensity = _ref.pointLightIntensity;
var BLOCHSPHERE = _constants.CONSTANTS.ELEMENT_TYPES.BLOCHSPHERE;
var x = origin.x,
y = origin.y,
z = origin.z;
var position = new _three.Vector3(radius + x, radius + y, radius + z);
var ambientLight = new _three.AmbientLight(ambientColor, ambientLightIntensity);
ambientLight.userData.themeControls = [_constants.THEME_SETTING_CONTROLS.ELEMENT_MESH_COLOR, _constants.THEME_SETTING_CONTROLS.INNER_LIGHT_INTENSITY];
var shaderLight = new _three.PointLight(0xffffff, 0, 0, 2);
shaderLight.userData.themeControls = [_constants.THEME_SETTING_CONTROLS.OUTER_LIGHT_INTENSITY];
if (elementType === BLOCHSPHERE) {
shaderLight.position.set(-position.x, position.y, -position.z);
shaderLight.intensity = pointLightIntensity;
} else {
shaderLight.position.set(position.x * 2, -position.y * 2, position.z);
shaderLight.intensity = pointLightIntensity / 3;
}
var innerLight = new _three.SpotLight(0xffffff, 1.3, radius * 2, Math.PI, 0, 0.5);
var offsetLight = new _three.HemisphereLight(0x111111, 0xffffff, 0.1);
innerLight.position.set(origin.x, origin.y, origin.z + radius / 2);
offsetLight.position.set(0 + x, -radius + y, 0 + z);
var lightsGroup = new _three.Group().add(ambientLight, shaderLight, offsetLight, innerLight);
return {
lightsGroup: lightsGroup,
ambientLight: ambientLight,
shaderLight: shaderLight
};
};
exports.default = _default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _three=require("three"),_constants=require("../../utils/constants"),_themeSettingsControls=require("../../utils/constants/themeSettingsControls"),_default=function(a,b,c,d){var e=b.ambientColor,f=b.ambientLightIntensity,g=b.pointLightIntensity,h=_constants.CONSTANTS.ELEMENT_TYPES.BLOCHSPHERE,i=c.x,j=c.y,k=c.z,l=new _three.Vector3(a+i,a+j,a+k),m=new _three.AmbientLight(e,f);m.userData.themeControls=[_themeSettingsControls.THEME_SETTING_CONTROLS.ELEMENT_MESH_COLOR,_themeSettingsControls.THEME_SETTING_CONTROLS.INNER_LIGHT_INTENSITY];var n=new _three.PointLight(16777215,0,0,2);n.userData.themeControls=[_themeSettingsControls.THEME_SETTING_CONTROLS.OUTER_LIGHT_INTENSITY],d===h?(n.position.set(-l.x,l.y,-l.z),n.intensity=g):(n.position.set(2*l.x,2*-l.y,l.z),n.intensity=g/3);var o=new _three.SpotLight(16777215,1.3,2*a,Math.PI,0,.5),p=new _three.HemisphereLight(1118481,16777215,.1);o.position.set(c.x,c.y,c.z+a/2),p.position.set(0+i,-a+j,0+k);var q=new _three.Group().add(m,n,p,o);return{lightsGroup:q,ambientLight:m,shaderLight:n}};exports.default=_default;

@@ -1,44 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _Line = require("../../utils/threejs/Line");
var _constants = require("../../utils/constants");
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var _default = function _default(originVector, currentPulseVector, _ref, _ref2) {
var color = _ref.color,
lineWidth = _ref.lineWidth;
var width = _ref2.width,
height = _ref2.height;
var positions = [].concat(_toConsumableArray(Object.values(originVector)), _toConsumableArray(Object.values(currentPulseVector)));
var pulseIndicatorGeometry = new _Line.LineGeometry();
pulseIndicatorGeometry.setPositions(positions);
var pulseIndicatorMaterial = new _Line.LineMaterial({
color: color,
linewidth: lineWidth,
polygonOffset: true,
polygonOffsetUnits: 1,
polygonOffsetFactor: -50
});
var line = new _Line.Line(pulseIndicatorGeometry, pulseIndicatorMaterial);
line.material.resolution.set(width, height);
line.userData = {
geometry: pulseIndicatorGeometry,
themeControls: [_constants.THEME_SETTING_CONTROLS.INDICATOR_COLOR]
};
return line;
};
exports.default = _default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _Line=require("../../utils/threejs/Line"),_themeSettingsControls=require("../../utils/constants/themeSettingsControls");function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}}var _default=function(a,b,c,d){var e=c.color,f=c.lineWidth,g=d.width,h=d.height,i=[].concat(_toConsumableArray(Object.values(a)),_toConsumableArray(Object.values(b))),j=new _Line.LineGeometry;j.setPositions(i);var k=new _Line.LineMaterial({color:e,linewidth:f,polygonOffset:!0,polygonOffsetUnits:1,polygonOffsetFactor:-50}),l=new _Line.Line(j,k);return l.material.resolution.set(g,h),l.userData={geometry:j,themeControls:[_themeSettingsControls.THEME_SETTING_CONTROLS.INDICATOR_COLOR]},l};exports.default=_default;

@@ -1,84 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _three = require("three");
var _Line = require("../../utils/threejs/Line");
var _createLineArcVerticesArray = require("../ElementMethods/createLineArcVerticesArray");
var _constants = require("../../utils/constants");
var _default = function _default(data, segmentIndexes, finalFrameIndex, _ref, _ref2, _ref3) {
var color = _ref.color,
lineWidth = _ref.lineWidth;
var currentSegmentLineWidth = _ref2.lineWidth;
var width = _ref3.width,
height = _ref3.height;
var continuousSegments = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true;
var drawArcs = arguments.length > 7 ? arguments[7] : undefined;
//
var segments = new _three.Group();
var segment = new _three.Group();
var geometry = new _Line.LineGeometry();
for (var i = 0; i <= finalFrameIndex; i++) {
var material = new _Line.LineMaterial({
color: color,
linewidth: lineWidth,
depthTest: true,
depthWrite: false,
polygonOffset: true,
polygonOffsetFactor: -100,
side: _three.BackSide
});
var linePositions = void 0;
if (drawArcs) {
linePositions = (0, _createLineArcVerticesArray.createLineArcVerticesArray)(data[i], data[i + 1] || data[i]);
} else {
linePositions = [data[i].x, data[i].y, data[i].z];
i < finalFrameIndex && linePositions.push(data[i + 1].x, data[i + 1].y, data[i + 1].z);
}
geometry.setPositions(linePositions);
var pathPiece = new _Line.Line(geometry, material);
pathPiece.userData.index = i;
pathPiece.userData.segmentIndex = segmentIndexes[i];
pathPiece.material.resolution.set(width, height);
segment.add(pathPiece);
if (segmentIndexes[i] !== segmentIndexes[i + 1] || i === finalFrameIndex) {
if (!continuousSegments) {
pathPiece.material.side = _three.BackSide;
pathPiece.userData.noDraw = true;
}
var segmentIndex = segmentIndexes[i];
segment.userData = {
segmentIndex: segmentIndex
};
segments.add(segment);
segment = new _three.Group();
}
geometry.dispose();
geometry = new _Line.LineGeometry();
}
segments.userData = {
themeControls: [_constants.THEME_SETTING_CONTROLS.PATH_COLOR, _constants.THEME_SETTING_CONTROLS.PATH_WEIGHT],
color: new _three.Color(color),
lineWidth: lineWidth,
currentSegmentLineWidth: currentSegmentLineWidth
};
return {
segments: segments
};
};
exports.default = _default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _three=require("three"),_Line=require("../../utils/threejs/Line"),_createLineArcVerticesArray=require("../ElementMethods/createLineArcVerticesArray"),_themeSettingsControls=require("../../utils/constants/themeSettingsControls"),_default=function(a,b,c,d,e,f){for(var g=d.color,h=d.lineWidth,j=e.lineWidth,k=f.width,l=f.height,m=!(6<arguments.length&&void 0!==arguments[6])||arguments[6],n=7<arguments.length?arguments[7]:void 0,o=new _three.Group,p=new _three.Group,q=new _Line.LineGeometry,r=0;r<=c;r++){var s=new _Line.LineMaterial({color:g,linewidth:h,depthTest:!0,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-100,side:_three.BackSide}),t=void 0;n?t=(0,_createLineArcVerticesArray.createLineArcVerticesArray)(a[r],a[r+1]||a[r]):(t=[a[r].x,a[r].y,a[r].z],r<c&&t.push(a[r+1].x,a[r+1].y,a[r+1].z)),q.setPositions(t);var u=new _Line.Line(q,s);if(u.userData.index=r,u.userData.segmentIndex=b[r],u.material.resolution.set(k,l),p.add(u),b[r]!==b[r+1]||r===c){m||(u.material.side=_three.BackSide,u.userData.noDraw=!0);var v=b[r];p.userData={segmentIndex:v},o.add(p),p=new _three.Group}q.dispose(),q=new _Line.LineGeometry}return o.userData={themeControls:[_themeSettingsControls.THEME_SETTING_CONTROLS.PATH_COLOR,_themeSettingsControls.THEME_SETTING_CONTROLS.PATH_WEIGHT],color:new _three.Color(g),lineWidth:h,currentSegmentLineWidth:j},{segments:o}};exports.default=_default;

@@ -1,117 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _three = require("three");
var _constants = require("../../utils/constants");
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var _default = function _default(_ref, _ref2, elementType, origin) {
var _ref$radius = _ref.radius,
radius = _ref$radius === void 0 ? _constants.CONSTANTS.RADIUS : _ref$radius,
opacity = _ref.opacity,
color = _ref.color,
outlineColor = _ref.outlineColor,
outlineOpacity = _ref.outlineOpacity,
roughness = _ref.roughness,
metalness = _ref.metalness;
var scalar = _ref2.scalar,
segments = _ref2.segments,
isPoint = _ref2.isPoint,
depth = _ref2.depth,
_ref2$outlineOnly = _ref2.outlineOnly,
outlineOnly = _ref2$outlineOnly === void 0 ? false : _ref2$outlineOnly;
var _CONSTANTS$ELEMENT_TY = _constants.CONSTANTS.ELEMENT_TYPES,
TETRAHEDRON = _CONSTANTS$ELEMENT_TY.TETRAHEDRON,
BLOCHSPHERE = _CONSTANTS$ELEMENT_TY.BLOCHSPHERE; // Shape material
var material;
var materialSettings = {
depthTest: depth,
color: color,
depthWrite: depth,
transparent: true,
opacity: outlineOnly ? opacity : 1,
side: _three.BackSide // allows objects/lines to be seen through sphere
};
if (isPoint) {
material = new _three.MeshBasicMaterial(materialSettings);
} else {
materialSettings.roughness = roughness;
materialSettings.metalness = metalness;
material = new _three.MeshStandardMaterial(materialSettings);
} // shape geometry
var geometry;
var outlineMesh;
var outlineMaterial;
var mesh;
var shape;
if (elementType === BLOCHSPHERE || !elementType) {
var _shape$position;
// sphere
geometry = new _three.SphereBufferGeometry(radius, segments, isPoint ? segments / 2 : segments);
mesh = new _three.Mesh(geometry, material);
mesh.name = "sphereMesh"; // sphere outline
outlineMaterial = new _three.MeshBasicMaterial({
color: outlineColor || color,
depthWrite: false,
side: _three.BackSide,
transparent: true,
opacity: outlineOpacity
});
outlineMesh = new _three.Mesh(geometry, outlineMaterial);
outlineMesh.scale.multiplyScalar(scalar);
shape = new _three.Group().add(mesh, outlineMesh);
elementType && (_shape$position = shape.position).set.apply(_shape$position, _toConsumableArray(Object.values(origin)));
} else if (elementType === TETRAHEDRON) {
var _shape$position2;
outlineMaterial = new _three.LineBasicMaterial({
color: outlineColor,
opacity: outlineOpacity,
depthTest: false,
transparent: true
}); // tetrahedron
geometry = new _three.TetrahedronBufferGeometry(Math.sqrt(3));
mesh = new _three.Mesh(geometry, material);
mesh.name = "tetrahedronMesh"; //tetrahedron outline
var edges = new _three.EdgesGeometry(geometry);
outlineMesh = new _three.LineSegments(edges, outlineMaterial);
shape = new _three.Group().add(mesh, outlineMesh);
shape.rotation.set(Math.PI, Math.PI / 2, Math.PI);
(_shape$position2 = shape.position).set.apply(_shape$position2, _toConsumableArray(Object.values(origin)));
}
outlineMesh.name = "outlineMesh";
material.userData.themeControls = [_constants.THEME_SETTING_CONTROLS.METALNESS, _constants.THEME_SETTING_CONTROLS.ROUGHNESS, _constants.THEME_SETTING_CONTROLS.OPACITY, _constants.THEME_SETTING_CONTROLS.ELEMENT_MESH_COLOR];
outlineMaterial.userData.themeControls = [_constants.THEME_SETTING_CONTROLS.SHOW_OUTLINES];
outlineMaterial.userData.opacity = outlineOpacity;
return {
meshGroup: shape,
material: material,
outlineMaterial: outlineMaterial
};
};
exports.default = _default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _three=require("three"),_constants=require("../../utils/constants"),_themeSettingsControls=require("../../utils/constants/themeSettingsControls");function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}}var _default=function(a,b,c,d){var e,f=a.radius,g=void 0===f?_constants.CONSTANTS.RADIUS:f,h=a.opacity,i=a.color,j=a.outlineColor,k=a.outlineOpacity,l=a.roughness,m=a.metalness,n=b.scalar,o=b.segments,p=b.isPoint,q=b.depth,r=b.outlineOnly,s=_constants.CONSTANTS.ELEMENT_TYPES,t=s.TETRAHEDRON,u=s.BLOCHSPHERE,v={depthTest:q,color:i,depthWrite:q,transparent:!0,opacity:void 0!==r&&r?h:1,side:_three.BackSide// allows objects/lines to be seen through sphere
};p?e=new _three.MeshBasicMaterial(v):(v.roughness=l,v.metalness=m,e=new _three.MeshStandardMaterial(v));// shape geometry
var w,x,y,z,A;if(c===u||!c){var B;w=new _three.SphereBufferGeometry(g,o,p?o/2:o),z=new _three.Mesh(w,e),z.name="sphereMesh",y=new _three.MeshBasicMaterial({color:j||i,depthWrite:!1,side:_three.BackSide,transparent:!0,opacity:k}),x=new _three.Mesh(w,y),x.scale.multiplyScalar(n),A=new _three.Group().add(z,x),c&&(B=A.position).set.apply(B,_toConsumableArray(Object.values(d)))}else if(c===t){var C;y=new _three.LineBasicMaterial({color:j,opacity:k,depthTest:!1,transparent:!0}),w=new _three.TetrahedronBufferGeometry(Math.sqrt(3)),z=new _three.Mesh(w,e),z.name="tetrahedronMesh";//tetrahedron outline
var D=new _three.EdgesGeometry(w);x=new _three.LineSegments(D,y),A=new _three.Group().add(z,x),A.rotation.set(Math.PI,Math.PI/2,Math.PI),(C=A.position).set.apply(C,_toConsumableArray(Object.values(d)))}return x.name="outlineMesh",e.userData.themeControls=[_themeSettingsControls.THEME_SETTING_CONTROLS.METALNESS,_themeSettingsControls.THEME_SETTING_CONTROLS.ROUGHNESS,_themeSettingsControls.THEME_SETTING_CONTROLS.OPACITY,_themeSettingsControls.THEME_SETTING_CONTROLS.ELEMENT_MESH_COLOR],y.userData.themeControls=[_themeSettingsControls.THEME_SETTING_CONTROLS.SHOW_OUTLINES],y.userData.opacity=k,{meshGroup:A,material:e,outlineMaterial:y}};exports.default=_default;

@@ -1,142 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
var _generateRenderer = _interopRequireDefault(require("./generateRenderer"));
var _canvasResize = _interopRequireDefault(require("../utils/threejs/canvasResize"));
var _Element = _interopRequireDefault(require("./Element"));
var _constants = require("../utils/constants");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var _default =
/*#__PURE__*/
function () {
function _default(canvasRef, elementDivs, initialFrameIndex, finalFrameIndex, continuousSegments, drawArcs, data, layout, canvasRect, nonErrorStateData) {
_classCallCheck(this, _default);
this.canvasRef = canvasRef;
this.renderer = (0, _generateRenderer.default)(canvasRef.current, canvasRect);
this.backgroundColor = layout.scene.backgroundColor;
this.elements = []; // create elements
for (var _i = 0, _Object$keys = Object.keys(elementDivs); _i < _Object$keys.length; _i++) {
var divName = _Object$keys[_i];
this.elements.push(new _Element.default(elementDivs[divName], data, layout, initialFrameIndex, finalFrameIndex, continuousSegments, drawArcs, canvasRect, nonErrorStateData));
}
this.canvasResize = (0, _canvasResize.default)(this.renderer, canvasRef, this.elements);
this.canvasResize.forceResize();
this.update = this.update.bind(this);
}
_createClass(_default, [{
key: "threeCleanup",
value: function threeCleanup() {
this.canvasResize.stop();
this.renderer.dispose();
this.renderer = undefined;
}
}, {
key: "updateThemeSettings",
value: function updateThemeSettings(settings) {
var bgColor = settings[_constants.THEME_SETTING_CONTROLS.BACKGROUND_COLOR.name];
this.backgroundColor = bgColor || this.backgroundColor;
}
}, {
key: "update",
value: function update(frameIndex, currentSegmentNumber, updates) {
var _this = this;
this.renderer.setClearColor(this.backgroundColor);
this.renderer.setScissorTest(false);
this.renderer.clear();
this.renderer.setClearColor(this.backgroundColor);
this.renderer.setScissorTest(true); // console.log(Color(this.backgroundColor).isLight());
this.elements.forEach(function (element) {
// get the element that is a place holder for where we want to
// draw the scene
var div = element.div; // get its position relative to the page's viewport
var rect = div.getBoundingClientRect(); // set the viewport
var width = rect.width,
height = rect.height,
left = rect.left,
bottom = rect.bottom;
var current = _this.canvasRef.current;
if (current) {
var _current$parentNode$g = current.parentNode.getBoundingClientRect(),
canvasLeft = _current$parentNode$g.left,
canvasBottom = _current$parentNode$g.bottom;
_this.renderer.setViewport(left - canvasLeft, canvasBottom - bottom, width, height);
_this.renderer.setScissor(left - canvasLeft, canvasBottom - bottom, width, height);
_this.renderer.render(element.scene, element.camera);
}
if ((0, _isEmpty2.default)(updates)) {
return;
}
element.update(frameIndex, currentSegmentNumber, updates);
});
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = updates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var update = _step.value;
var method = update.method,
_update$args = update.args,
args = _update$args === void 0 ? [] : _update$args;
this[method] && this[method].apply(this, _toConsumableArray(args));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
}]);
return _default;
}();
exports.default = _default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _isEmpty2=_interopRequireDefault(require("lodash/isEmpty")),_generateRenderer=_interopRequireDefault(require("./generateRenderer")),_canvasResize=_interopRequireDefault(require("../utils/threejs/canvasResize")),_Element=_interopRequireDefault(require("./Element")),_themeSettingsControls=require("../utils/constants/themeSettingsControls");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}var _default=/*#__PURE__*/function(){function a(b,c,d,e,f,g,h,i,j,k){_classCallCheck(this,a),this.canvasRef=b,this.renderer=(0,_generateRenderer.default)(b,j),this.backgroundColor=i.scene.backgroundColor,this.elements=[];// create elements
for(var l,m=0,n=Object.keys(c);m<n.length;m++)l=n[m],this.elements.push(new _Element.default(c[l],h,i,d,e,f,g,j,k));this.canvasResize=(0,_canvasResize.default)(this.renderer,b,this.elements),this.canvasResize.forceResize(),this.update=this.update.bind(this)}return _createClass(a,[{key:"threeCleanup",value:function threeCleanup(){this.canvasResize.stop(),this.renderer.dispose(),this.renderer=void 0}},{key:"updateThemeSettings",value:function updateThemeSettings(a){var b=a[_themeSettingsControls.THEME_SETTING_CONTROLS.BACKGROUND_COLOR.name];this.backgroundColor=b||this.backgroundColor}},{key:"update",value:function(a,b,c){var d=this;this.renderer.setClearColor(this.backgroundColor),this.renderer.setScissorTest(!1),this.renderer.clear(),this.renderer.setClearColor(this.backgroundColor),this.renderer.setScissorTest(!0),this.elements.forEach(function(e){// get the element that is a place holder for where we want to
// draw the scene
var f=e.div,g=f.getBoundingClientRect(),h=g.width,i=g.height,j=g.left,k=g.bottom;// get its position relative to the page's viewport
if(d.canvasRef){var l=d.canvasRef.parentNode.getBoundingClientRect(),m=l.left,n=l.bottom;d.renderer.setViewport(j-m,n-k,h,i),d.renderer.setScissor(j-m,n-k,h,i),d.renderer.render(e.scene,e.camera)}(0,_isEmpty2.default)(c)||e.update(a,b,c)});var e=!0,f=!1,g=void 0;try{for(var h,i=c[Symbol.iterator]();!(e=(h=i.next()).done);e=!0){var j=h.value,k=j.method,l=j.args,m=void 0===l?[]:l;this[k]&&this[k].apply(this,_toConsumableArray(m))}}catch(a){f=!0,g=a}finally{try{e||null==i.return||i.return()}finally{if(f)throw g}}}}]),a}();exports.default=_default;

@@ -1,8 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SEGMENT_OPACITIES = void 0;
var SEGMENT_OPACITIES = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
exports.SEGMENT_OPACITIES = SEGMENT_OPACITIES;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SEGMENT_OPACITIES=void 0;var SEGMENT_OPACITIES=[.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.2,.2,.2,.2,.2,.2,.2,.2,.2,.2,.3,.3,.3,.3,.3,.3,.3,.3,.3,.3,.4,.4,.4,.4,.4,.4,.4,.4,.4,.4,.5,.5,.5,.5,.5,.5,.5,.5,.5,.5,.6,.6,.6,.6,.6,.6,.6,.6,.6,.6,.7,.7,.7,.7,.7,.7,.7,.7,.7,.7,.8,.8,.8,.8,.8,.8,.8,.8,.8,.8,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,1,1,1,1,1,1,1,1,1,1];exports.SEGMENT_OPACITIES=SEGMENT_OPACITIES;

@@ -1,279 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CAMERA_PRESETS = exports.AVAILABLE_THEME_CONTROLS = exports.THEME_SETTING_CONTROLS = exports.GRID_TEMPLATE_NAMES = exports.CONSTANTS = void 0;
var _updatePulsePathDisplay = _interopRequireDefault(require("../../threeJs/ElementMethods/updatePulsePathDisplay"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var CONSTANTS = {
THREE_OBJECT_TYPES: {
GROUP: "Group",
SPRITE: "Sprite",
MESH: "Mesh",
LINE: "Line",
LINE2: "Line2"
},
CAMERA_PRESETS: {
TETRAHEDRON: {
XY: {
x: 0,
y: 0,
z: 11.8
},
YZ: {
x: 11.8,
y: 0,
z: 0
},
XZ: {
x: 0,
y: -11.8,
z: 0
},
DEFAULT: {
x: 7,
y: 7,
z: 6.5
}
},
BLOCHSPHERE: {
XY: {
x: 0,
y: 0,
z: 9.45
},
YZ: {
x: 9.45,
y: 0,
z: 0
},
XZ: {
x: 0,
y: -9.45,
z: 0
},
DEFAULT: {
x: 7,
y: -5.55,
z: 3
}
}
},
NAMES: {
LABELS: {
THETA: "theta",
PHI: "phi",
THETA_ARC: "theta",
PHI_ARC: "phi",
NON_ERROR_STATE: "nonErrorState",
PULSE_INDICATOR: "pulseIndicator"
}
},
ELEMENT_GROUPS: ["qubits", "vectors"],
ELEMENT_TYPES: {
BLOCHSPHERE: "blochSphere",
TETRAHEDRON: "tetrahedron"
},
ELEMENT_IDS: {
ONE: "qubit1",
TWO: "qubit2",
A: "a",
B: "b",
C: "c"
},
ELEMENT_REGEX_STRINGS: {
BLOCHSPHERE: ["blochphere", "qubit"],
TETRAHEDRON: ["tetrahedron", "tetrahedra", "vector"]
},
SCENE_OBJECT_UPDATE_TYPES: {
UPDATE_PULSE_POSITION: "updatePulseAnimation",
CLEAR_SEGMENT_HIGHLIGHTS: "clearSegmentHighlights",
SHOW_OR_HIDE_LABELS: "showOrHideLabels",
SET_CAMERA_PRESET: "setCameraPreset",
SET_COORDINATE_ARCS: "setCoordinateArcs",
UPDATE_THEME_SETTINGS: "updateThemeSettings",
THREE_CLEANUP: "threeCleanup"
},
RADIUS: 1,
ARC_SMOOTHNESS: 20,
RAYCASTER_LINE_PRECISION: 0.1
};
exports.CONSTANTS = CONSTANTS;
var GRID_TEMPLATE_NAMES = {
TWO_QUBIT_ENTANGLEMENT: "twoQubitEntanglement"
};
exports.GRID_TEMPLATE_NAMES = GRID_TEMPLATE_NAMES;
var THEME_SETTING_CONTROLS = {
ELEMENT_MESH_COLOR: {
name: "elementMeshColor",
type: "color-slider",
threeUpdateMethod: function threeUpdateMethod(obj, val) {
return obj.color.set(val);
} // will be either a material or a light (ambient light color)
},
BACKGROUND_COLOR: {
name: "backgroundColor",
type: "color"
},
OPACITY: {
name: "opacity",
type: "slider",
min: 0,
max: 1,
step: 0.01,
threeUpdateMethod: function threeUpdateMethod(material, val) {
return material.opacity = val;
}
},
METALNESS: {
name: "metalness",
type: "slider",
min: 0,
max: 1,
step: 0.01,
threeUpdateMethod: function threeUpdateMethod(material, val) {
return material.metalness = val;
}
},
ROUGHNESS: {
name: "roughness",
type: "slider",
min: 0,
max: 1,
step: 0.01,
threeUpdateMethod: function threeUpdateMethod(material, val) {
return material.roughness = val;
}
},
INNER_LIGHT_INTENSITY: {
name: "innerLightIntensity",
type: "slider",
min: 0,
max: 5,
step: 0.001,
threeUpdateMethod: function threeUpdateMethod(light, val) {
return light.intensity = val;
}
},
OUTER_LIGHT_INTENSITY: {
name: "outerLightIntensity",
type: "slider",
min: 0,
max: 15,
step: 0.01,
threeUpdateMethod: function threeUpdateMethod(light, val) {
return light.intensity = val;
}
},
PATH_WEIGHT: {
name: "pathWeight",
type: "number",
min: 1,
max: 10,
step: 1,
threeUpdateMethod: function threeUpdateMethod(segmentsGroup, newLineWidth) {
var lineWidth = segmentsGroup.userData.lineWidth;
var currentSegmentLineWidth = segmentsGroup.userData.currentSegmentLineWidth;
var newCurrentSegmentLineWidth = newLineWidth + (currentSegmentLineWidth - lineWidth);
segmentsGroup.userData.lineWidth = newLineWidth;
segmentsGroup.userData.currentSegmentLineWidth = newCurrentSegmentLineWidth;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = segmentsGroup.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var segment = _step.value;
(0, _updatePulsePathDisplay.default)(segment, {
lineWidth: newLineWidth
});
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
},
PATH_COLOR: {
name: "pathColor",
type: "color",
threeUpdateMethod: function threeUpdateMethod(_ref, newColor) {
var children = _ref.children,
color = _ref.userData.color;
color.set(newColor);
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = children[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var segment = _step2.value;
(0, _updatePulsePathDisplay.default)(segment, {
color: color
});
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
},
HIGHLIGHT_COLOR: {
name: "highlightColor",
type: "color",
threeUpdateMethod: function threeUpdateMethod(obj, val) {
return obj.color && obj.color.set(val) || obj.set(val);
}
},
NON_ERROR_STATE_DOT_COLOR: {
name: "nonErrorStateDotColor",
type: "color",
threeUpdateMethod: function threeUpdateMethod(obj, val) {
return obj.material.color.set(val);
}
},
INDICATOR_COLOR: {
name: "indicatorColor",
type: "color",
threeUpdateMethod: function threeUpdateMethod(obj, val) {
return obj.material.color.set(val);
}
},
SHOW_OUTLINES: {
name: "showOutlines",
type: "switch",
threeUpdateMethod: function threeUpdateMethod(material, show) {
return material.opacity = show ? material.userData.opacity : 0;
}
}
};
exports.THEME_SETTING_CONTROLS = THEME_SETTING_CONTROLS;
var AVAILABLE_THEME_CONTROLS = Object.values(THEME_SETTING_CONTROLS);
exports.AVAILABLE_THEME_CONTROLS = AVAILABLE_THEME_CONTROLS;
var CAMERA_PRESETS = Object.keys(CONSTANTS.CAMERA_PRESETS.BLOCHSPHERE);
exports.CAMERA_PRESETS = CAMERA_PRESETS;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CAMERA_PRESETS=exports.AVAILABLE_CONFIGURATIONS=exports.TOOLTIPS=exports.GATE_TIMING=exports.CONSTANTS=void 0;var CONSTANTS={THREE_OBJECT_TYPES:{GROUP:"Group",SPRITE:"Sprite",MESH:"Mesh",LINE:"Line",LINE2:"Line2"},CAMERA_PRESETS:{TETRAHEDRON:{XY:{x:0,y:0,z:11.8},YZ:{x:11.8,y:0,z:0},XZ:{x:0,y:-11.8,z:0},DEFAULT:{x:7,y:7,z:6.5}},BLOCHSPHERE:{XY:{x:0,y:0,z:9.45},YZ:{x:9.45,y:0,z:0},XZ:{x:0,y:-9.45,z:0},DEFAULT:{x:7,y:-5.55,z:3}}},NAMES:{LABELS:{THETA:"theta",PHI:"phi",THETA_ARC:"theta",PHI_ARC:"phi",NON_ERROR_STATE:"nonErrorState",PULSE_INDICATOR:"pulseIndicator"}},ELEMENT_GROUPS:["qubits","vectors"],ELEMENT_TYPES:{BLOCHSPHERE:"blochSphere",TETRAHEDRON:"tetrahedron"},ELEMENT_IDS:{ONE:"qubit1",TWO:"qubit2",A:"a",B:"b",C:"c"},ELEMENT_REGEX_STRINGS:{BLOCHSPHERE:["blochphere","qubit"],TETRAHEDRON:["tetrahedron","tetrahedra","vector"]},SCENE_OBJECT_UPDATE_TYPES:{UPDATE_PULSE_POSITION:"updatePulseAnimation",CLEAR_SEGMENT_HIGHLIGHTS:"clearSegmentHighlights",SHOW_OR_HIDE_LABELS:"showOrHideLabels",SET_CAMERA_PRESET:"setCameraPreset",SET_COORDINATE_ARCS:"setCoordinateArcs",UPDATE_THEME_SETTINGS:"updateThemeSettings",THREE_CLEANUP:"threeCleanup"},RADIUS:1,ARC_SMOOTHNESS:20,RAYCASTER_LINE_PRECISION:.1};exports.CONSTANTS=CONSTANTS;var GATE_TIMING=45;// TODO: use internationalisation for tooltips?
exports.GATE_TIMING=45;var TOOLTIPS={nonErrorState:"Non Error Trajectory"};exports.TOOLTIPS=TOOLTIPS;var AVAILABLE_CONFIGURATIONS={ONE_QUBIT:"oneQubit",TWO_QUBIT_ENTANGLEMENT:"twoQubitEntanglement"};exports.AVAILABLE_CONFIGURATIONS=AVAILABLE_CONFIGURATIONS;var CAMERA_PRESETS=Object.keys(CONSTANTS.CAMERA_PRESETS.BLOCHSPHERE);exports.CAMERA_PRESETS=CAMERA_PRESETS;

@@ -1,18 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = function _default(a, b) {
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
_ref$rtol = _ref.rtol,
rtol = _ref$rtol === void 0 ? 1e-5 : _ref$rtol,
_ref$atol = _ref.atol,
atol = _ref$atol === void 0 ? 1e-8 : _ref$atol;
return Math.abs(a - b) <= atol + rtol * Math.abs(b) ? true : false;
};
exports.default = _default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _default=function(c,a){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},d=b.rtol,e=void 0===d?1e-5:d,f=b.atol,g=void 0===f?1e-8:f;return!!(Math.abs(c-a)<=g+e*Math.abs(a))};exports.default=_default;

@@ -1,9 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
// This THREEx helper makes it easy to handle window resize.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;// This THREEx helper makes it easy to handle window resize.
// It will update renderer and camera when window is resized.

@@ -22,3 +15,2 @@ //

//
/**

@@ -29,44 +21,5 @@ * Update renderer and camera when the window is resized

* @param {Object} Camera the camera to update
*/
var _default = function _default(renderer, canvasRef, elements) {
var callback = function callback() {
var canvasNode = canvasRef.current;
var _canvasNode$parentNod = canvasNode.parentNode.getBoundingClientRect(),
canvasWidth = _canvasNode$parentNod.width,
canvasHeight = _canvasNode$parentNod.height;
canvasNode.width = canvasWidth;
canvasNode.height = canvasHeight;
elements.forEach(function (element) {
var camera = element.camera,
div = element.div;
var _div$getBoundingClien = div.getBoundingClientRect(),
width = _div$getBoundingClien.width,
height = _div$getBoundingClien.height;
canvasNode.width = width;
canvasNode.height = height;
camera.aspect = width / height;
camera.updateProjectionMatrix();
}); // notify the renderer of the size change
renderer.setSize(canvasWidth, canvasHeight); // update the camera
}; // bind the resize event
window.addEventListener("resize", callback); // return .stop() the function to stop watching window resize
return {
// Stop watching window resize
stop: function stop() {
window.removeEventListener("resize", callback);
},
forceResize: function forceResize() {
callback();
}
};
};
exports.default = _default;
*/var _default=function(a,b,c){var d=function(){var d=b,e=d.parentNode.getBoundingClientRect(),f=e.width,g=e.height;d.width=f,d.height=g,c.forEach(function(a){var b=a.camera,c=a.div,e=c.getBoundingClientRect(),f=e.width,g=e.height;d.width=f,d.height=g,b.aspect=f/g,b.updateProjectionMatrix()}),a.setSize(f,g)};// bind the resize event
// return .stop() the function to stop watching window resize
return window.addEventListener("resize",d),{// Stop watching window resize
stop:function stop(){window.removeEventListener("resize",d)},forceResize:function forceResize(){d()}}};exports.default=_default;

@@ -1,38 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = function _default() {
if (!!window.WebGLRenderingContext) {
var canvas = document.createElement("canvas"),
names = ["webgl2", "webgl", "experimental-webgl", "moz-webgl", "webkit-3d"],
context = false;
for (var i = 0; i < names.length; i++) {
try {
context = canvas.getContext(names[i]);
if (context && typeof context.getParameter === "function") {
// WebGL is enabled
return true;
}
} catch (e) {}
} // WebGL is supported, but disabled
var _error = new Error("WebGL is supported, but disabled");
_error.name = "WebGl";
throw _error;
} // WebGL not supported
var error = new Error("WebGL not supported");
error.name = "WebGl";
throw error;
};
exports.default = _default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _default=function(a){try{if(!!window.WebGLRenderingContext){for(var b=document.createElement("canvas"),c=["webgl2","webgl","experimental-webgl","moz-webgl","webkit-3d"],d=!1,e=0;e<c.length;e++)try{if(d=b.getContext(c[e]),d&&"function"==typeof d.getParameter)return!0;/////////////////// WebGL is enabled
}catch(a){}// WebGL is supported, but disabled
var f=new Error("WebGL is supported, but disabled");throw f.name="WebGl",f}// WebGL not supported
var g=new Error("WebGL not supported");throw g.name="WebGl",g}catch(b){console.log(b),a.push(b)}};exports.default=_default;

@@ -1,16 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getVectorFromDataObject = void 0;
var getVectorFromDataObject = function getVectorFromDataObject(frameIndex, dataObject) {
return dataObject ? {
x: dataObject.x[frameIndex],
y: dataObject.y[frameIndex],
z: dataObject.z[frameIndex]
} : {};
};
exports.getVectorFromDataObject = getVectorFromDataObject;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getVectorFromDataObject=void 0;var getVectorFromDataObject=function(a,b){return b?{x:b.x[a],y:b.y[a],z:b.z[a]}:{}};exports.getVectorFromDataObject=getVectorFromDataObject;

@@ -1,31 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "LineGeometry", {
enumerable: true,
get: function get() {
return _LineGeometry.default;
}
});
Object.defineProperty(exports, "LineMaterial", {
enumerable: true,
get: function get() {
return _LineMaterial.default;
}
});
Object.defineProperty(exports, "Line", {
enumerable: true,
get: function get() {
return _Line.default;
}
});
var _LineGeometry = _interopRequireDefault(require("./LineGeometry"));
var _LineMaterial = _interopRequireDefault(require("./LineMaterial"));
var _Line = _interopRequireDefault(require("./Line2"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"LineGeometry",{enumerable:!0,get:function get(){return _LineGeometry.default}}),Object.defineProperty(exports,"LineMaterial",{enumerable:!0,get:function get(){return _LineMaterial.default}}),Object.defineProperty(exports,"Line",{enumerable:!0,get:function get(){return _Line.default}});var _LineGeometry=_interopRequireDefault(require("./LineGeometry")),_LineMaterial=_interopRequireDefault(require("./LineMaterial")),_Line=_interopRequireDefault(require("./Line2"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}

@@ -1,39 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _LineSegments = _interopRequireDefault(require("./LineSegments2"));
var _LineGeometry = _interopRequireDefault(require("./LineGeometry"));
var _LineMaterial = _interopRequireDefault(require("./LineMaterial"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _LineSegments=_interopRequireDefault(require("./LineSegments2")),_LineGeometry=_interopRequireDefault(require("./LineGeometry")),_LineMaterial=_interopRequireDefault(require("./LineMaterial"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}/**
* @author WestLangley / http://github.com/WestLangley
*
*/
var Line2 = function Line2(geometry, material) {
_LineSegments.default.call(this);
this.type = 'Line2';
this.geometry = geometry !== undefined ? geometry : new _LineGeometry.default();
this.material = material !== undefined ? material : new _LineMaterial.default({
color: Math.random() * 0xffffff
});
};
Line2.prototype = Object.assign(Object.create(_LineSegments.default.prototype), {
constructor: Line2,
isLine2: true,
copy: function copy(source) {
// todo
return this;
}
});
var _default = Line2;
exports.default = _default;
*/var Line2=function(a,b){_LineSegments.default.call(this),this.type="Line2",this.geometry=a===void 0?new _LineGeometry.default:a,this.material=b===void 0?new _LineMaterial.default({color:16777215*Math.random()}):b};Line2.prototype=Object.assign(Object.create(_LineSegments.default.prototype),{constructor:Line2,isLine2:!0,copy:function copy(){return this}});var _default=Line2;exports.default=_default;

@@ -1,75 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _LineSegmentsGeometry = _interopRequireDefault(require("./LineSegmentsGeometry"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var LineGeometry = function LineGeometry() {
_LineSegmentsGeometry.default.call(this);
this.type = 'LineGeometry';
};
LineGeometry.prototype = Object.assign(Object.create(_LineSegmentsGeometry.default.prototype), {
constructor: LineGeometry,
isLineGeometry: true,
setPositions: function setPositions(array) {
// converts [ x1, y1, z1, x2, y2, z2, ... ] to pairs format
var length = array.length - 3;
var points = new Float32Array(2 * length);
for (var i = 0; i < length; i += 3) {
points[2 * i] = array[i];
points[2 * i + 1] = array[i + 1];
points[2 * i + 2] = array[i + 2];
points[2 * i + 3] = array[i + 3];
points[2 * i + 4] = array[i + 4];
points[2 * i + 5] = array[i + 5];
}
_LineSegmentsGeometry.default.prototype.setPositions.call(this, points);
return this;
},
setColors: function setColors(array) {
// converts [ r1, g1, b1, r2, g2, b2, ... ] to pairs format
var length = array.length - 3;
var colors = new Float32Array(2 * length);
for (var i = 0; i < length; i += 3) {
colors[2 * i] = array[i];
colors[2 * i + 1] = array[i + 1];
colors[2 * i + 2] = array[i + 2];
colors[2 * i + 3] = array[i + 3];
colors[2 * i + 4] = array[i + 4];
colors[2 * i + 5] = array[i + 5];
}
_LineSegmentsGeometry.default.prototype.setColors.call(this, colors);
return this;
},
fromLine: function fromLine(line) {
var geometry = line.geometry;
if (geometry.isGeometry) {
this.setPositions(geometry.vertices);
} else if (geometry.isBufferGeometry) {
this.setPositions(geometry.position.array); // assumes non-indexed
} // set colors, maybe
return this;
},
copy: function copy(source) {
// todo
return this;
}
});
var _default = LineGeometry;
exports.default = _default;
"use strict";var _LineSegmentsGeometry=_interopRequireDefault(require("./LineSegmentsGeometry"));Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var LineGeometry=function(){_LineSegmentsGeometry.default.call(this),this.type="LineGeometry"};LineGeometry.prototype=Object.assign(Object.create(_LineSegmentsGeometry.default.prototype),{constructor:LineGeometry,isLineGeometry:!0,setPositions:function setPositions(a){// converts [ x1, y1, z1, x2, y2, z2, ... ] to pairs format
for(var b=a.length-3,c=new Float32Array(2*b),d=0;d<b;d+=3)c[2*d]=a[d],c[2*d+1]=a[d+1],c[2*d+2]=a[d+2],c[2*d+3]=a[d+3],c[2*d+4]=a[d+4],c[2*d+5]=a[d+5];return _LineSegmentsGeometry.default.prototype.setPositions.call(this,c),this},setColors:function setColors(a){// converts [ r1, g1, b1, r2, g2, b2, ... ] to pairs format
for(var b=a.length-3,c=new Float32Array(2*b),d=0;d<b;d+=3)c[2*d]=a[d],c[2*d+1]=a[d+1],c[2*d+2]=a[d+2],c[2*d+3]=a[d+3],c[2*d+4]=a[d+4],c[2*d+5]=a[d+5];return _LineSegmentsGeometry.default.prototype.setColors.call(this,c),this},fromLine:function fromLine(a){var b=a.geometry;// set colors, maybe
return b.isGeometry?this.setPositions(b.vertices):b.isBufferGeometry&&this.setPositions(b.position.array),this},copy:function copy(){return this}});var _default=LineGeometry;exports.default=_default;

@@ -1,130 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _three = require("three");
/**
* @author WestLangley / http://github.com/WestLangley
*
* parameters = {
* color: <hex>,
* linewidth: <float>,
* dashed: <boolean>,
* dashScale: <float>,
* dashSize: <float>,
* gapSize: <float>,
* resolution: <Vector2>, // to be set by renderer
* }
*/
_three.UniformsLib.line = {
linewidth: {
value: 1
},
resolution: {
value: new _three.Vector2(1, 1)
},
dashScale: {
value: 1
},
dashSize: {
value: 1
},
gapSize: {
value: 1 // todo FIX - maybe change to totalSize
}
};
_three.ShaderLib['line'] = {
uniforms: _three.UniformsUtils.merge([_three.UniformsLib.common, _three.UniformsLib.fog, _three.UniformsLib.line]),
vertexShader: "\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec2 ndcStart = clipStart.xy / clipStart.w;\n\t\t\tvec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd - ndcStart;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t// perpendicular to dir\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",
fragmentShader: "\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t}\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n\t\t\t#include <premultiplied_alpha_fragment>\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\n\t\t}\n\t\t"
};
var LineMaterial = function LineMaterial(parameters) {
_three.ShaderMaterial.call(this, {
type: 'LineMaterial',
uniforms: _three.UniformsUtils.clone(_three.ShaderLib['line'].uniforms),
vertexShader: _three.ShaderLib['line'].vertexShader,
fragmentShader: _three.ShaderLib['line'].fragmentShader
});
this.dashed = false;
Object.defineProperties(this, {
color: {
enumerable: true,
get: function get() {
return this.uniforms.diffuse.value;
},
set: function set(value) {
this.uniforms.diffuse.value = value;
}
},
linewidth: {
enumerable: true,
get: function get() {
return this.uniforms.linewidth.value;
},
set: function set(value) {
this.uniforms.linewidth.value = value;
}
},
dashScale: {
enumerable: true,
get: function get() {
return this.uniforms.dashScale.value;
},
set: function set(value) {
this.uniforms.dashScale.value = value;
}
},
dashSize: {
enumerable: true,
get: function get() {
return this.uniforms.dashSize.value;
},
set: function set(value) {
this.uniforms.dashSize.value = value;
}
},
gapSize: {
enumerable: true,
get: function get() {
return this.uniforms.gapSize.value;
},
set: function set(value) {
this.uniforms.gapSize.value = value;
}
},
resolution: {
enumerable: true,
get: function get() {
return this.uniforms.resolution.value;
},
set: function set(value) {
this.uniforms.resolution.value.copy(value);
}
}
});
this.setValues(parameters);
};
LineMaterial.prototype = Object.create(_three.ShaderMaterial.prototype);
LineMaterial.prototype.constructor = LineMaterial;
LineMaterial.prototype.isLineMaterial = true;
LineMaterial.prototype.copy = function (source) {
_three.ShaderMaterial.prototype.copy.call(this, source);
this.color.copy(source.color);
this.linewidth = source.linewidth;
this.resolution = source.resolution; // todo
return this;
};
var _default = LineMaterial;
exports.default = _default;
"use strict";var _three=require("three");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;_three.UniformsLib.line={linewidth:{value:1},resolution:{value:new _three.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},_three.ShaderLib.line={uniforms:_three.UniformsUtils.merge([_three.UniformsLib.common,_three.UniformsLib.fog,_three.UniformsLib.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec2 ndcStart = clipStart.xy / clipStart.w;\n\t\t\tvec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd - ndcStart;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t// perpendicular to dir\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; \n\n\t\t\t#endif\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t}\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n\t\t\t#include <premultiplied_alpha_fragment>\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\n\t\t}\n\t\t"};var LineMaterial=function(a){_three.ShaderMaterial.call(this,{type:"LineMaterial",uniforms:_three.UniformsUtils.clone(_three.ShaderLib.line.uniforms),vertexShader:_three.ShaderLib.line.vertexShader,fragmentShader:_three.ShaderLib.line.fragmentShader}),this.dashed=!1,Object.defineProperties(this,{color:{enumerable:!0,get:function get(){return this.uniforms.diffuse.value},set:function set(a){this.uniforms.diffuse.value=a}},linewidth:{enumerable:!0,get:function get(){return this.uniforms.linewidth.value},set:function set(a){this.uniforms.linewidth.value=a}},dashScale:{enumerable:!0,get:function get(){return this.uniforms.dashScale.value},set:function set(a){this.uniforms.dashScale.value=a}},dashSize:{enumerable:!0,get:function get(){return this.uniforms.dashSize.value},set:function set(a){this.uniforms.dashSize.value=a}},gapSize:{enumerable:!0,get:function get(){return this.uniforms.gapSize.value},set:function set(a){this.uniforms.gapSize.value=a}},resolution:{enumerable:!0,get:function get(){return this.uniforms.resolution.value},set:function set(a){this.uniforms.resolution.value.copy(a)}}}),this.setValues(a)};LineMaterial.prototype=Object.create(_three.ShaderMaterial.prototype),LineMaterial.prototype.constructor=LineMaterial,LineMaterial.prototype.isLineMaterial=!0,LineMaterial.prototype.copy=function(a){return _three.ShaderMaterial.prototype.copy.call(this,a),this.color.copy(a.color),this.linewidth=a.linewidth,this.resolution=a.resolution,this};var _default=LineMaterial;exports.default=_default;

@@ -1,65 +0,7 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _three = require("three");
var _LineSegmentsGeometry = _interopRequireDefault(require("./LineSegmentsGeometry"));
var _LineMaterial = _interopRequireDefault(require("./LineMaterial"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _three=require("three"),_LineSegmentsGeometry=_interopRequireDefault(require("./LineSegmentsGeometry")),_LineMaterial=_interopRequireDefault(require("./LineMaterial"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}/**
* @author WestLangley / http://github.com/WestLangley
*
*/
var LineSegments2 = function LineSegments2(geometry, material) {
_three.Mesh.call(this);
this.type = 'LineSegments2';
this.geometry = geometry !== undefined ? geometry : new _LineSegmentsGeometry.default();
this.material = material !== undefined ? material : new _LineMaterial.default({
color: Math.random() * 0xffffff
});
};
LineSegments2.prototype = Object.assign(Object.create(_three.Mesh.prototype), {
constructor: LineSegments2,
isLineSegments2: true,
computeLineDistances: function () {
// for backwards-compatability, but could be a method of LineSegmentsGeometry...
var start = new _three.Vector3();
var end = new _three.Vector3();
return function computeLineDistances() {
var geometry = this.geometry;
var instanceStart = geometry.attributes.instanceStart;
var instanceEnd = geometry.attributes.instanceEnd;
var lineDistances = new Float32Array(2 * instanceStart.data.count);
for (var i = 0, j = 0, l = instanceStart.data.count; i < l; i++, j += 2) {
start.fromBufferAttribute(instanceStart, i);
end.fromBufferAttribute(instanceEnd, i);
lineDistances[j] = j === 0 ? 0 : lineDistances[j - 1];
lineDistances[j + 1] = lineDistances[j] + start.distanceTo(end);
}
var instanceDistanceBuffer = new _three.InstancedInterleavedBuffer(lineDistances, 2, 1); // d0, d1
geometry.addAttribute('instanceDistanceStart', new _three.InterleavedBufferAttribute(instanceDistanceBuffer, 1, 0)); // d0
geometry.addAttribute('instanceDistanceEnd', new _three.InterleavedBufferAttribute(instanceDistanceBuffer, 1, 1)); // d1
return this;
};
}(),
copy: function copy(source) {
// todo
return this;
}
});
var _default = LineSegments2;
exports.default = _default;
*/var LineSegments2=function(a,b){_three.Mesh.call(this),this.type="LineSegments2",this.geometry=a===void 0?new _LineSegmentsGeometry.default:a,this.material=b===void 0?new _LineMaterial.default({color:16777215*Math.random()}):b};LineSegments2.prototype=Object.assign(Object.create(_three.Mesh.prototype),{constructor:LineSegments2,isLineSegments2:!0,computeLineDistances:function(){// for backwards-compatability, but could be a method of LineSegmentsGeometry...
var a=new _three.Vector3,b=new _three.Vector3;return function(){for(var c=this.geometry,d=c.attributes.instanceStart,e=c.attributes.instanceEnd,f=new Float32Array(2*d.data.count),g=0,h=0,k=d.data.count;g<k;g++,h+=2)a.fromBufferAttribute(d,g),b.fromBufferAttribute(e,g),f[h]=0==h?0:f[h-1],f[h+1]=f[h]+a.distanceTo(b);var l=new _three.InstancedInterleavedBuffer(f,2,1);// d0, d1
// d1
return c.addAttribute("instanceDistanceStart",new _three.InterleavedBufferAttribute(l,1,0)),c.addAttribute("instanceDistanceEnd",new _three.InterleavedBufferAttribute(l,1,1)),this}}(),copy:function copy(){return this}});var _default=LineSegments2;exports.default=_default;

@@ -1,172 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _three = require("three");
/**
* @author WestLangley / http://github.com/WestLangley
*
*/
var LineSegmentsGeometry = function LineSegmentsGeometry() {
_three.InstancedBufferGeometry.call(this);
this.type = "LineSegmentsGeometry";
var positions = [-1, 2, 0, 1, 2, 0, -1, 1, 0, 1, 1, 0, -1, 0, 0, 1, 0, 0, -1, -1, 0, 1, -1, 0];
var uvs = [-1, 2, 1, 2, -1, 1, 1, 1, -1, -1, 1, -1, -1, -2, 1, -2];
var index = [0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5];
this.setIndex(index);
this.addAttribute("position", new _three.Float32BufferAttribute(positions, 3));
this.addAttribute("uv", new _three.Float32BufferAttribute(uvs, 2));
};
LineSegmentsGeometry.prototype = Object.assign(Object.create(_three.InstancedBufferGeometry.prototype), {
constructor: LineSegmentsGeometry,
isLineSegmentsGeometry: true,
applyMatrix: function applyMatrix(matrix) {
var start = this.attributes.instanceStart;
var end = this.attributes.instanceEnd;
if (start !== undefined) {
matrix.applyToBufferAttribute(start);
matrix.applyToBufferAttribute(end);
start.data.needsUpdate = true;
}
if (this.boundingBox !== null) {
this.computeBoundingBox();
}
if (this.boundingSphere !== null) {
this.computeBoundingSphere();
}
return this;
},
setPositions: function setPositions(array) {
var lineSegments;
if (array instanceof Float32Array) {
lineSegments = array;
} else if (Array.isArray(array)) {
lineSegments = new Float32Array(array);
}
var instanceBuffer = new _three.InstancedInterleavedBuffer(lineSegments, 6, 1); // xyz, xyz
this.addAttribute("instanceStart", new _three.InterleavedBufferAttribute(instanceBuffer, 3, 0)); // xyz
this.addAttribute("instanceEnd", new _three.InterleavedBufferAttribute(instanceBuffer, 3, 3)); // xyz
//
this.computeBoundingBox();
this.computeBoundingSphere();
return this;
},
setColors: function setColors(array) {
var colors;
if (array instanceof Float32Array) {
colors = array;
} else if (Array.isArray(array)) {
colors = new Float32Array(array);
}
var instanceColorBuffer = new _three.InstancedInterleavedBuffer(colors, 6, 1); // rgb, rgb
this.addAttribute("instanceColorStart", new _three.InterleavedBufferAttribute(instanceColorBuffer, 3, 0)); // rgb
this.addAttribute("instanceColorEnd", new _three.InterleavedBufferAttribute(instanceColorBuffer, 3, 3)); // rgb
return this;
},
fromWireframeGeometry: function fromWireframeGeometry(geometry) {
this.setPositions(geometry.attributes.position.array);
return this;
},
fromEdgesGeometry: function fromEdgesGeometry(geometry) {
this.setPositions(geometry.attributes.position.array);
return this;
},
fromMesh: function fromMesh(mesh) {
this.fromWireframeGeometry(new _three.WireframeGeometry(mesh.geometry)); // set colors, maybe
return this;
},
fromLineSegements: function fromLineSegements(lineSegments) {
var geometry = lineSegments.geometry;
if (geometry.isGeometry) {
this.setPositions(geometry.vertices);
} else if (geometry.isBufferGeometry) {
this.setPositions(geometry.position.array); // assumes non-indexed
} // set colors, maybe
return this;
},
computeBoundingBox: function () {
var box = new _three.Box3();
return function computeBoundingBox() {
if (this.boundingBox === null) {
this.boundingBox = new _three.Box3();
}
var start = this.attributes.instanceStart;
var end = this.attributes.instanceEnd;
if (start !== undefined && end !== undefined) {
this.boundingBox.setFromBufferAttribute(start);
box.setFromBufferAttribute(end);
this.boundingBox.union(box);
}
};
}(),
computeBoundingSphere: function () {
var vector = new _three.Vector3();
return function computeBoundingSphere() {
if (this.boundingSphere === null) {
this.boundingSphere = new _three.Sphere();
}
if (this.boundingBox === null) {
this.computeBoundingBox();
}
var start = this.attributes.instanceStart;
var end = this.attributes.instanceEnd;
if (start !== undefined && end !== undefined) {
var center = this.boundingSphere.center;
this.boundingBox.getCenter(center);
var maxRadiusSq = 0;
for (var i = 0, il = start.count; i < il; i++) {
vector.fromBufferAttribute(start, i);
maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(vector));
vector.fromBufferAttribute(end, i);
maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(vector));
}
this.boundingSphere.radius = Math.sqrt(maxRadiusSq);
if (isNaN(this.boundingSphere.radius)) {
console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.", this);
}
}
};
}(),
toJSON: function toJSON() {// todo
},
clone: function clone() {// todo
},
copy: function copy(source) {
// todo
return this;
}
});
var _default = LineSegmentsGeometry;
exports.default = _default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _three=require("three"),LineSegmentsGeometry=function(){_three.InstancedBufferGeometry.call(this),this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.addAttribute("position",new _three.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.addAttribute("uv",new _three.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))};LineSegmentsGeometry.prototype=Object.assign(Object.create(_three.InstancedBufferGeometry.prototype),{constructor:LineSegmentsGeometry,isLineSegmentsGeometry:!0,applyMatrix:function applyMatrix(a){var b=this.attributes.instanceStart,c=this.attributes.instanceEnd;return void 0!==b&&(a.applyToBufferAttribute(b),a.applyToBufferAttribute(c),b.data.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},setPositions:function setPositions(a){var b;a instanceof Float32Array?b=a:Array.isArray(a)&&(b=new Float32Array(a));var c=new _three.InstancedInterleavedBuffer(b,6,1);// xyz, xyz
return this.addAttribute("instanceStart",new _three.InterleavedBufferAttribute(c,3,0)),this.addAttribute("instanceEnd",new _three.InterleavedBufferAttribute(c,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this},setColors:function setColors(a){var b;a instanceof Float32Array?b=a:Array.isArray(a)&&(b=new Float32Array(a));var c=new _three.InstancedInterleavedBuffer(b,6,1);// rgb, rgb
// rgb
return this.addAttribute("instanceColorStart",new _three.InterleavedBufferAttribute(c,3,0)),this.addAttribute("instanceColorEnd",new _three.InterleavedBufferAttribute(c,3,3)),this},fromWireframeGeometry:function fromWireframeGeometry(a){return this.setPositions(a.attributes.position.array),this},fromEdgesGeometry:function fromEdgesGeometry(a){return this.setPositions(a.attributes.position.array),this},fromMesh:function fromMesh(a){// set colors, maybe
return this.fromWireframeGeometry(new _three.WireframeGeometry(a.geometry)),this},fromLineSegements:function fromLineSegements(a){var b=a.geometry;// set colors, maybe
return b.isGeometry?this.setPositions(b.vertices):b.isBufferGeometry&&this.setPositions(b.position.array),this},computeBoundingBox:function(){var a=new _three.Box3;return function(){null===this.boundingBox&&(this.boundingBox=new _three.Box3);var b=this.attributes.instanceStart,c=this.attributes.instanceEnd;b!==void 0&&c!==void 0&&(this.boundingBox.setFromBufferAttribute(b),a.setFromBufferAttribute(c),this.boundingBox.union(a))}}(),computeBoundingSphere:function(){var a=new _three.Vector3;return function(){null===this.boundingSphere&&(this.boundingSphere=new _three.Sphere),null===this.boundingBox&&this.computeBoundingBox();var b=this.attributes.instanceStart,c=this.attributes.instanceEnd;if(b!==void 0&&c!==void 0){var d=this.boundingSphere.center;this.boundingBox.getCenter(d);for(var e=0,f=0,g=b.count;f<g;f++)a.fromBufferAttribute(b,f),e=Math.max(e,d.distanceToSquared(a)),a.fromBufferAttribute(c,f),e=Math.max(e,d.distanceToSquared(a));this.boundingSphere.radius=Math.sqrt(e),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}}(),toJSON:function toJSON(){},clone:function clone(){},copy:function copy(){return this}});var _default=LineSegmentsGeometry;exports.default=_default;

@@ -1,72 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _three = require("three");
var _find2 = _interopRequireDefault(require("lodash/find"));
var _getElementType = _interopRequireDefault(require("../../threeJs/ElementMethods/getElementType"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = function _default(data, dataSize, layout, elementNames, dataGroupKeys) {
var elementTypes = layout.elementTypes;
var vectorisedData = {};
for (var element in elementNames) {
var elementType = (0, _getElementType.default)(element);
var origin = elementTypes[elementType].origin;
var x = origin.x,
y = origin.y,
z = origin.z;
var elementData = void 0;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = dataGroupKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var key = _step.value;
var found = (0, _find2.default)(data[key], {
name: element
});
if (found) {
elementData = found;
break;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
vectorisedData[element] = [];
for (var i = 0; i <= dataSize; i++) {
var vx = elementData.x[i] + x;
var vy = elementData.y[i] + y;
var vz = elementData.z[i] + z;
var vector = new _three.Vector3(vx, vy, vz);
vectorisedData[element].push(vector);
}
}
return vectorisedData;
};
exports.default = _default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _three=require("three"),_constants=require("../constants"),_default=function(a,b,c){var d=c.elementTypes,e=_constants.CONSTANTS.ELEMENT_TYPES,f={};return a.qubits.forEach(function(a){var c=a.name,g=a.x,h=a.y,i=a.z;return pushData({elementTypes:d,elementType:e.BLOCHSPHERE,name:c,x:g,y:h,z:i,dataSize:b,vectorisedData:f})}),a.vectors&&a.vectors.forEach(function(a){var c=a.name,g=a.x,h=a.y,i=a.z;return pushData({elementTypes:d,elementType:e.TETRAHEDRON,name:c,x:g,y:h,z:i,dataSize:b,vectorisedData:f})}),f};exports.default=_default;var pushData=function(a){var b=a.elementTypes,c=a.elementType,d=a.name,e=a.x,f=a.y,g=a.z,h=a.dataSize,j=a.vectorisedData,k=b[c].origin,l=k.x,m=k.y,n=k.z;j[d]=[];for(var s=0;s<=h;s++){var o=e[s]+l,p=f[s]+m,q=g[s]+n,r=new _three.Vector3(o,p,q);j[d].push(r)}};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc