senangwebs-aframe-editor 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +3 -0
- package/.editorconfig +12 -0
- package/.eslintignore +2 -0
- package/.eslintrc +40 -0
- package/.github/workflows/ci.yml +39 -0
- package/.husky/pre-commit +4 -0
- package/.prettierignore +1 -0
- package/.prettierrc.json +5 -0
- package/.stylelintrc +12 -0
- package/LICENSE +21 -0
- package/README.md +75 -0
- package/assets/gltf.svg +49 -0
- package/dist/aframe-inspector.js +106250 -0
- package/dist/aframe-inspector.js.map +1 -0
- package/dist/aframe-inspector.min.js +29040 -0
- package/dist/aframe-inspector.min.js.LICENSE.txt +56 -0
- package/dist/aframe-inspector.min.js.map +1 -0
- package/examples/360video.html +48 -0
- package/examples/colors.html +18 -0
- package/examples/controllers.html +60 -0
- package/examples/embedded-zoom.html +78 -0
- package/examples/embedded.html +79 -0
- package/examples/empty.html +13 -0
- package/examples/index-aframe.html +66 -0
- package/examples/index.html +71 -0
- package/examples/supercraft.html +6 -0
- package/index.html +8 -0
- package/package.json +84 -0
- package/senangwebs-webverse-editor.png +0 -0
- package/src/components/AwesomeIcon.js +53 -0
- package/src/components/Collapsible.js +57 -0
- package/src/components/EntityRepresentation.js +83 -0
- package/src/components/Main.js +222 -0
- package/src/components/__tests__/Collapsible.test.js +30 -0
- package/src/components/components/AddComponent.js +104 -0
- package/src/components/components/CommonComponents.js +160 -0
- package/src/components/components/Component.js +151 -0
- package/src/components/components/ComponentsContainer.js +52 -0
- package/src/components/components/DefaultComponents.js +1 -0
- package/src/components/components/Mixins.js +83 -0
- package/src/components/components/PropertyRow.js +145 -0
- package/src/components/components/Sidebar.js +51 -0
- package/src/components/icons/BackViewIcon.js +27 -0
- package/src/components/icons/BottomViewIcon.js +26 -0
- package/src/components/icons/FrontViewIcon.js +23 -0
- package/src/components/icons/LeftViewIcon.js +24 -0
- package/src/components/icons/PerspectiveIcon.js +23 -0
- package/src/components/icons/PrimitiveBoxIcon.js +143 -0
- package/src/components/icons/PrimitiveConeIcon.js +44 -0
- package/src/components/icons/PrimitiveCylinderIcon.js +51 -0
- package/src/components/icons/PrimitiveEmptyEntityIcon.js +78 -0
- package/src/components/icons/PrimitiveImageIcon.js +86 -0
- package/src/components/icons/PrimitiveLightIcon.js +107 -0
- package/src/components/icons/PrimitivePlaneIcon.js +87 -0
- package/src/components/icons/PrimitiveSphereIcon.js +39 -0
- package/src/components/icons/PrimitiveTextIcon.js +89 -0
- package/src/components/icons/PrimitiveTorusIcon.js +31 -0
- package/src/components/icons/RightViewIcon.js +24 -0
- package/src/components/icons/TopViewIcon.js +24 -0
- package/src/components/modals/Modal.js +107 -0
- package/src/components/modals/ModalHelp.js +97 -0
- package/src/components/modals/ModalPrimitive.js +114 -0
- package/src/components/modals/ModalTextures.js +430 -0
- package/src/components/scenegraph/Entity.js +142 -0
- package/src/components/scenegraph/SceneGraph.js +337 -0
- package/src/components/scenegraph/Toolbar.js +147 -0
- package/src/components/viewport/CameraToolbar.js +122 -0
- package/src/components/viewport/TransformToolbar.js +102 -0
- package/src/components/viewport/ViewportHUD.js +33 -0
- package/src/components/widgets/BooleanWidget.js +49 -0
- package/src/components/widgets/ColorWidget.js +89 -0
- package/src/components/widgets/InputWidget.js +42 -0
- package/src/components/widgets/NumberWidget.js +179 -0
- package/src/components/widgets/SelectWidget.js +58 -0
- package/src/components/widgets/TextureWidget.js +252 -0
- package/src/components/widgets/Vec2Widget.js +55 -0
- package/src/components/widgets/Vec3Widget.js +58 -0
- package/src/components/widgets/Vec4Widget.js +61 -0
- package/src/components/widgets/index.js +9 -0
- package/src/index.js +301 -0
- package/src/lib/EditorControls.js +336 -0
- package/src/lib/Events.js +6 -0
- package/src/lib/TransformControls.js +1365 -0
- package/src/lib/assetsLoader.js +43 -0
- package/src/lib/assetsUtils.js +30 -0
- package/src/lib/cameras.js +121 -0
- package/src/lib/entity.js +556 -0
- package/src/lib/history.js +30 -0
- package/src/lib/raycaster.js +129 -0
- package/src/lib/shortcuts.js +211 -0
- package/src/lib/utils.js +118 -0
- package/src/lib/viewport.js +268 -0
- package/src/style/components.styl +275 -0
- package/src/style/entity.styl +22 -0
- package/src/style/help.styl +40 -0
- package/src/style/index.styl +358 -0
- package/src/style/lib.styl +41 -0
- package/src/style/primitiveModal.styl +90 -0
- package/src/style/scenegraph.styl +173 -0
- package/src/style/select.styl +71 -0
- package/src/style/textureModal.styl +220 -0
- package/src/style/viewport.styl +168 -0
- package/src/style/widgets.styl +71 -0
- package/webpack.config.js +65 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import Events from './Events';
|
|
2
|
+
|
|
3
|
+
const assetsBaseUrl =
|
|
4
|
+
window.AFRAME_SAMPLE_ASSETS_ROOT || 'https://aframe.io/sample-assets/';
|
|
5
|
+
const assetsRelativeUrl = { images: 'dist/images.json' };
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Asynchronously load and register components from the registry.
|
|
9
|
+
*/
|
|
10
|
+
export function AssetsLoader() {
|
|
11
|
+
this.images = [];
|
|
12
|
+
this.hasLoaded = false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
AssetsLoader.prototype = {
|
|
16
|
+
/**
|
|
17
|
+
* XHR the assets JSON.
|
|
18
|
+
*/
|
|
19
|
+
load: function () {
|
|
20
|
+
var xhr = new XMLHttpRequest();
|
|
21
|
+
var url = assetsBaseUrl + assetsRelativeUrl.images;
|
|
22
|
+
|
|
23
|
+
// @todo Remove the sync call and use a callback
|
|
24
|
+
xhr.open('GET', url);
|
|
25
|
+
|
|
26
|
+
xhr.onload = () => {
|
|
27
|
+
var data = JSON.parse(xhr.responseText);
|
|
28
|
+
this.images = data.images;
|
|
29
|
+
this.images.forEach((image) => {
|
|
30
|
+
image.fullPath = assetsBaseUrl + data.basepath.images + image.path;
|
|
31
|
+
image.fullThumbPath =
|
|
32
|
+
assetsBaseUrl + data.basepath.images_thumbnails + image.thumbnail;
|
|
33
|
+
});
|
|
34
|
+
Events.emit('assetsimagesload', this.images);
|
|
35
|
+
};
|
|
36
|
+
xhr.onerror = () => {
|
|
37
|
+
console.error('Error loading registry file.');
|
|
38
|
+
};
|
|
39
|
+
xhr.send();
|
|
40
|
+
|
|
41
|
+
this.hasLoaded = true;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function insertNewAsset(
|
|
2
|
+
type,
|
|
3
|
+
id,
|
|
4
|
+
src,
|
|
5
|
+
anonymousCrossOrigin,
|
|
6
|
+
onLoadedCallback
|
|
7
|
+
) {
|
|
8
|
+
var element = null;
|
|
9
|
+
switch (type) {
|
|
10
|
+
case 'img':
|
|
11
|
+
{
|
|
12
|
+
element = document.createElement('img');
|
|
13
|
+
element.id = id;
|
|
14
|
+
element.src = src;
|
|
15
|
+
if (anonymousCrossOrigin) {
|
|
16
|
+
element.crossOrigin = 'anonymous';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (element) {
|
|
23
|
+
element.onload = function () {
|
|
24
|
+
if (onLoadedCallback) {
|
|
25
|
+
onLoadedCallback();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
document.getElementsByTagName('a-assets')[0].appendChild(element);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import Events from './Events';
|
|
2
|
+
|
|
3
|
+
// Save ortho camera FOV / position before switching to restore later.
|
|
4
|
+
let currentOrthoDir = '';
|
|
5
|
+
const orthoCameraMemory = {
|
|
6
|
+
left: { position: new THREE.Vector3(-10, 0, 0), rotation: new THREE.Euler() },
|
|
7
|
+
right: { position: new THREE.Vector3(10, 0, 0), rotation: new THREE.Euler() },
|
|
8
|
+
top: { position: new THREE.Vector3(0, 10, 0), rotation: new THREE.Euler() },
|
|
9
|
+
bottom: {
|
|
10
|
+
position: new THREE.Vector3(0, -10, 0),
|
|
11
|
+
rotation: new THREE.Euler()
|
|
12
|
+
},
|
|
13
|
+
back: { position: new THREE.Vector3(0, 0, -10), rotation: new THREE.Euler() },
|
|
14
|
+
front: { position: new THREE.Vector3(0, 0, 10), rotation: new THREE.Euler() }
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Initialize various cameras, store original one.
|
|
19
|
+
*/
|
|
20
|
+
export function initCameras(inspector) {
|
|
21
|
+
const sceneEl = inspector.sceneEl;
|
|
22
|
+
|
|
23
|
+
const originalCamera = (inspector.currentCameraEl = sceneEl.camera.el);
|
|
24
|
+
inspector.currentCameraEl.setAttribute(
|
|
25
|
+
'data-aframe-inspector-original-camera',
|
|
26
|
+
''
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// If the current camera is the default, we should prevent AFRAME from
|
|
30
|
+
// remove it once when we inject the editor's camera.
|
|
31
|
+
if (inspector.currentCameraEl.hasAttribute('data-aframe-default-camera')) {
|
|
32
|
+
inspector.currentCameraEl.removeAttribute('data-aframe-default-camera');
|
|
33
|
+
inspector.currentCameraEl.setAttribute(
|
|
34
|
+
'data-aframe-inspector',
|
|
35
|
+
'default-camera'
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
inspector.currentCameraEl.setAttribute('camera', 'active', false);
|
|
40
|
+
|
|
41
|
+
// Create Inspector camera.
|
|
42
|
+
const perspectiveCamera = (inspector.camera = new THREE.PerspectiveCamera());
|
|
43
|
+
perspectiveCamera.far = 10000;
|
|
44
|
+
perspectiveCamera.near = 0.01;
|
|
45
|
+
perspectiveCamera.position.set(0, 1.6, 2);
|
|
46
|
+
perspectiveCamera.lookAt(new THREE.Vector3(0, 1.6, -1));
|
|
47
|
+
perspectiveCamera.updateMatrixWorld();
|
|
48
|
+
sceneEl.object3D.add(perspectiveCamera);
|
|
49
|
+
sceneEl.camera = perspectiveCamera;
|
|
50
|
+
|
|
51
|
+
const ratio = sceneEl.canvas.width / sceneEl.canvas.height;
|
|
52
|
+
const orthoCamera = new THREE.OrthographicCamera(
|
|
53
|
+
-10 * ratio,
|
|
54
|
+
10 * ratio,
|
|
55
|
+
10,
|
|
56
|
+
-10
|
|
57
|
+
);
|
|
58
|
+
sceneEl.object3D.add(orthoCamera);
|
|
59
|
+
|
|
60
|
+
const cameras = (inspector.cameras = {
|
|
61
|
+
perspective: perspectiveCamera,
|
|
62
|
+
original: originalCamera,
|
|
63
|
+
ortho: orthoCamera
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Command to switch to perspective.
|
|
67
|
+
Events.on('cameraperspectivetoggle', () => {
|
|
68
|
+
saveOrthoCamera(inspector.camera, currentOrthoDir);
|
|
69
|
+
sceneEl.camera = inspector.camera = cameras.perspective;
|
|
70
|
+
Events.emit('cameratoggle', {
|
|
71
|
+
camera: inspector.camera,
|
|
72
|
+
value: 'perspective'
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Command to switch to ortographic.
|
|
77
|
+
Events.on('cameraorthographictoggle', (dir) => {
|
|
78
|
+
saveOrthoCamera(inspector.camera, currentOrthoDir);
|
|
79
|
+
sceneEl.camera = inspector.camera = cameras.ortho;
|
|
80
|
+
currentOrthoDir = dir;
|
|
81
|
+
setOrthoCamera(cameras.ortho, dir, ratio);
|
|
82
|
+
|
|
83
|
+
// Set initial rotation for the respective orthographic camera.
|
|
84
|
+
if (
|
|
85
|
+
cameras.ortho.rotation.x === 0 &&
|
|
86
|
+
cameras.ortho.rotation.y === 0 &&
|
|
87
|
+
cameras.ortho.rotation.z === 0
|
|
88
|
+
) {
|
|
89
|
+
cameras.ortho.lookAt(0, 0, 0);
|
|
90
|
+
}
|
|
91
|
+
Events.emit('cameratoggle', {
|
|
92
|
+
camera: inspector.camera,
|
|
93
|
+
value: `ortho${dir}`
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return inspector.cameras;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function saveOrthoCamera(camera, dir) {
|
|
101
|
+
if (camera.type !== 'OrthographicCamera') {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const info = orthoCameraMemory[dir];
|
|
105
|
+
info.position.copy(camera.position);
|
|
106
|
+
info.rotation.copy(camera.rotation);
|
|
107
|
+
info.left = camera.left;
|
|
108
|
+
info.right = camera.right;
|
|
109
|
+
info.top = camera.top;
|
|
110
|
+
info.bottom = camera.bottom;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function setOrthoCamera(camera, dir, ratio) {
|
|
114
|
+
const info = orthoCameraMemory[dir];
|
|
115
|
+
camera.left = info.left || -10 * ratio;
|
|
116
|
+
camera.right = info.right || 10 * ratio;
|
|
117
|
+
camera.top = info.top || 10;
|
|
118
|
+
camera.bottom = info.bottom || -10;
|
|
119
|
+
camera.position.copy(info.position);
|
|
120
|
+
camera.rotation.copy(info.rotation);
|
|
121
|
+
}
|