@bezlepkin/nativescript-ar
Version:
NativeScript Augmented Reality plugin. ARKit on iOS and (with the help of Sceneform) ARCore on Android.
33 lines (32 loc) • 1.58 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ARModel = void 0;
const core_1 = require("@nativescript/core");
const arcommon_1 = require("./arcommon");
class ARModel extends arcommon_1.ARCommonNode {
static create(options) {
console.log(">> create ARModel");
return new Promise((resolve, reject) => {
ARModel.download("https://github.com/EddyVerbruggen/nativescript-ar/raw/master/demo/app/App_Resources/iOS/Models.scnassets/Car.dae")
.then((file) => {
const data = NSFileManager.defaultManager.contentsAtPath(file);
const sceneSource = SCNSceneSource.sceneSourceWithDataOptions(data, null);
const arr = sceneSource.identifiersOfEntriesWithClass(SCNMaterial.class());
console.log(">> identifiers: " + arr.count);
let modelScene = SCNScene.sceneWithURLOptionsError(NSURL.URLWithString(file), null);
console.log(">> modelScene: " + modelScene);
let nodeModel = options.childNodeName ? modelScene.rootNode.childNodeWithNameRecursively(options.childNodeName, true) : modelScene.rootNode;
resolve(new ARModel(options, nodeModel));
});
});
}
static download(url) {
return new Promise((resolve, reject) => {
core_1.Http.getFile(url).then((file) => {
console.log(">>> downloaded to " + file.path);
resolve(file.path);
}, (e) => reject(e));
});
}
}
exports.ARModel = ARModel;