Skip to content

Commit

Permalink
testing AR.js-core
Browse files Browse the repository at this point in the history
  • Loading branch information
kalwalt committed Dec 19, 2024
1 parent 363c4e8 commit 7bfc66c
Show file tree
Hide file tree
Showing 15 changed files with 644 additions and 362 deletions.
3 changes: 2 additions & 1 deletion aframe/build/aframe-ar-new-location-only.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion aframe/build/aframe-ar-new-location-only.module.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion aframe/build/aframe-ar-nft.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion aframe/build/aframe-ar-nft.module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion aframe/build/aframe-ar.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions aframe/build/aframe-ar.module.js

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions aframe/examples/marker-based/simple.html
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>
13 changes: 7 additions & 6 deletions aframe/src/component-anchor-nft.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as AFRAME from 'aframe';
import Anchor from '../../three.js/src/new-api/arjs-anchor';
import { AnchorDebugUI } from '../../three.js/src/new-api/arjs-debugui';
import ArToolkitContext from '../../three.js/src/threex/arjs-context';

//import Anchor from '../../three.js/src/new-api/arjs-anchor';
//import {Anchor} from '@ar-js-org/arjs-core';
import ARjsCore from '@ar-js-org/arjs-core';
const { Anchor, AnchorDebugUI, Context} = ARjsCore;
console.log(Anchor)
////////////////////////////////////////////////////////////////////////////////
// arjs-anchor
//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -100,11 +101,11 @@ AFRAME.registerComponent('arjs-anchor', {

if (_this.data.preset === 'hiro') {
markerParameters.type = 'pattern'
markerParameters.patternUrl = ArToolkitContext.baseURL + 'examples/marker-training/examples/pattern-files/pattern-hiro.patt'
markerParameters.patternUrl = Context.baseURL + 'examples/marker-training/examples/pattern-files/pattern-hiro.patt'
markerParameters.markersAreaEnabled = false
} else if (_this.data.preset === 'kanji') {
markerParameters.type = 'pattern'
markerParameters.patternUrl = ArToolkitContext.baseURL + 'examples/marker-training/examples/pattern-files/pattern-kanji.patt'
markerParameters.patternUrl = Context.baseURL + 'examples/marker-training/examples/pattern-files/pattern-kanji.patt'
markerParameters.markersAreaEnabled = false
} else if (_this.data.preset === 'area') {
markerParameters.type = 'barcode'
Expand Down
22 changes: 16 additions & 6 deletions aframe/src/component-anchor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import * as AFRAME from 'aframe';
import Anchor from '../../three.js/src/new-api/arjs-anchor';
import { AnchorDebugUI } from '../../three.js/src/new-api/arjs-debugui';
import ArToolkitContext from '../../three.js/src/threex/arjs-context';
//import {ARjsCore} from '@ar-js-org/arjs-core';
import ARjsCore from '@ar-js-org/arjs-core';
import { log } from 'aframe';
const {Anchor, AnchorDebugUI, Context} = ARjsCore;
//import { AnchorDebugUI } from '@ar-js-org/arjs-core';
//import {ArToolkitContext} from '@ar-js-org/arjs-core';



//console.log(Anchor)

////////////////////////////////////////////////////////////////////////////////
// arjs-anchor
Expand Down Expand Up @@ -59,6 +66,9 @@ AFRAME.registerComponent('arjs-anchor', {
init: function () {
var _this = this

console.log(this.el.sceneEl.systems.arjs);


// get arjsSystem
var arjsSystem = this.el.sceneEl.systems.arjs || this.el.sceneEl.systems.artoolkit

Expand Down Expand Up @@ -97,11 +107,11 @@ AFRAME.registerComponent('arjs-anchor', {

if (_this.data.preset === 'hiro') {
markerParameters.type = 'pattern'
markerParameters.patternUrl = ArToolkitContext.baseURL + 'examples/marker-training/examples/pattern-files/pattern-hiro.patt'
markerParameters.patternUrl = Context.baseURL + 'examples/marker-training/examples/pattern-files/pattern-hiro.patt'
markerParameters.markersAreaEnabled = false
} else if (_this.data.preset === 'kanji') {
markerParameters.type = 'pattern'
markerParameters.patternUrl = ArToolkitContext.baseURL + 'examples/marker-training/examples/pattern-files/pattern-kanji.patt'
markerParameters.patternUrl = Context.baseURL + 'examples/marker-training/examples/pattern-files/pattern-kanji.patt'
markerParameters.markersAreaEnabled = false
} else if (_this.data.preset === 'area') {
markerParameters.type = 'barcode'
Expand Down Expand Up @@ -174,7 +184,7 @@ AFRAME.registerComponent('arjs-anchor', {
//////////////////////////////////////////////////////////////////////////////
var arWorldRoot = this._arAnchor.object3d
arWorldRoot.updateMatrixWorld(true)
arWorldRoot.matrixWorld.decompose(this.el.object3D.position, this.el.object3D.quaternion, this.el.object3D.scale)
//arWorldRoot.matrixWorld.decompose(this.el.object3D.position, this.el.object3D.quaternion, this.el.object3D.scale)

//////////////////////////////////////////////////////////////////////////////
// honor visibility
Expand Down
9 changes: 5 additions & 4 deletions aframe/src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Components
import "./component-anchor";
import "./component-hit-testing";
//import "./component-anchor";
//import "./component-hit-testing";

// Location-based components
import "./location-based/arjs-look-controls";
/*import "./location-based/arjs-look-controls";
import "./location-based/arjs-webcam-texture";
import "./location-based/ArjsDeviceOrientationControls";
import "./location-based/gps-camera";
Expand All @@ -12,7 +12,8 @@ import "./location-based/gps-projected-camera";
import "./location-based/gps-projected-entity-place";
import "./new-location-based/gps-new-camera";
import "./new-location-based/gps-new-entity-place";
import "./new-location-based/arjs-device-orientation-controls";
import "./new-location-based/arjs-device-orientation-controls";*/

// System
import "./test";
import "./system-arjs";
6 changes: 3 additions & 3 deletions aframe/src/system-arjs-nft.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as AFRAME from 'aframe';
import Profile from '../../three.js/src/threex/arjs-profile';
import Session from '../../three.js/src/new-api/arjs-session-nft';
import { SessionDebugUI } from '../../three.js/src/new-api/arjs-debugui';
import {Profile} from '@ar-js-org/arjs-core';
import {Session} from '@ar-js-org/arjs-core';
import { SessionDebugUI } from '@ar-js-org/arjs-core';

AFRAME.registerSystem('arjs', {
schema: {
Expand Down
11 changes: 8 additions & 3 deletions aframe/src/system-arjs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import * as AFRAME from 'aframe';
import Profile from '../../three.js/src/threex/arjs-profile';
import Session from '../../three.js/src/new-api/arjs-session';
import { SessionDebugUI } from '../../three.js/src/new-api/arjs-debugui';
import ARjsCore from '@ar-js-org/arjs-core';
const {Profile, Session, SessionDebugUI} = ARjsCore;
/*import {Profile} from '@ar-js-org/arjs-core';
import {Session} from '@ar-js-org/arjs-core';
import { SessionDebugUI } from '@ar-js-org/arjs-core';*/

console.log(Profile)

AFRAME.registerSystem('arjs', {
schema: {
Expand Down Expand Up @@ -103,6 +107,7 @@ AFRAME.registerSystem('arjs', {

init: function () {
var _this = this
console.info("init")

// If videoTexture is set, skip the remainder of the setup entirely and just use the arjs-webcam-texture component
if(this.data.videoTexture === true && this.data.sourceType === 'webcam') {
Expand Down
62 changes: 62 additions & 0 deletions aframe/src/test.js
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);
}
},
});
Loading

0 comments on commit 7bfc66c

Please sign in to comment.