-
Notifications
You must be signed in to change notification settings - Fork 942
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
644 additions
and
362 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<script src="https://cdn.jsdelivr.net/gh/aframevr/[email protected]/dist/aframe-master.min.js"></script> | ||
<!-- include aframe-ar.js --> | ||
<script src="../../build/aframe-ar.js"></script> | ||
|
||
<body style='margin : 0px; overflow: hidden; font-family: Monospace;'><div style='position: fixed; top: 10px; width:100%; text-align: center; z-index: 1;'> | ||
<a href="https://github.com/AR-js-org/AR.js/" target="_blank">AR.js</a> - example for a-frame | ||
<br/> | ||
Contact me any time at <a href='https://twitter.com/nicolocarp' target='_blank'>@nicolocarp</a> | ||
</div> | ||
|
||
<a-scene embedded arjs='sourceType: image; sourceUrl:../../data/images/armchair.jpg;'> | ||
<!--<a-scene arjs='sourceType: webcam;' renderer='antialias: true; alpha: true; precision: medium;'>--> | ||
<!--<a-scene >--> | ||
<a-entity position="-1 0.5 -3" test="width:4; height:4; depth:4; color:red"></a-entity> | ||
</a-scene> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import * as AFRAME from "aframe"; | ||
|
||
AFRAME.registerComponent("test", { | ||
schema: { | ||
width: { type: "number", default: 1 }, | ||
height: { type: "number", default: 1 }, | ||
depth: { type: "number", default: 1 }, | ||
color: { type: "color", default: "#AAA" }, | ||
}, | ||
|
||
/** | ||
* Initial creation and setting of the mesh. | ||
*/ | ||
init: function () { | ||
var data = this.data; | ||
var el = this.el; | ||
console.log(data); | ||
|
||
// Create geometry. | ||
this.geometry = new THREE.BoxGeometry(data.width, data.height, data.depth); | ||
|
||
// Create material. | ||
this.material = new THREE.MeshStandardMaterial({ color: data.color }); | ||
|
||
// Create mesh. | ||
this.mesh = new THREE.Mesh(this.geometry, this.material); | ||
|
||
// Set mesh on entity. | ||
el.setObject3D("mesh", this.mesh); | ||
}, | ||
/** | ||
* Update the mesh in response to property updates. | ||
*/ | ||
update: function (oldData) { | ||
var data = this.data; | ||
var el = this.el; | ||
|
||
// If `oldData` is empty, then this means we're in the initialization process. | ||
// No need to update. | ||
if (Object.keys(oldData).length === 0) { | ||
return; | ||
} | ||
|
||
// Geometry-related properties changed. Update the geometry. | ||
if ( | ||
data.width !== oldData.width || | ||
data.height !== oldData.height || | ||
data.depth !== oldData.depth | ||
) { | ||
el.getObject3D("mesh").geometry = new THREE.BoxGeometry( | ||
data.width, | ||
data.height, | ||
data.depth, | ||
); | ||
} | ||
|
||
// Material-related properties changed. Update the material. | ||
if (data.color !== oldData.color) { | ||
el.getObject3D("mesh").material.color = new THREE.Color(data.color); | ||
} | ||
}, | ||
}); |
Oops, something went wrong.