Closed maxTeste closed 3 years ago
I had Similar Issue when I Started Working on this Plugin, which I overcame eventually It's not a Bug, It has something todo with Settings on scn in XCODE when you add file to SCENE xcassets and than adding proper Light in scene.
That's how I fixed it.
resolved. property in relation to light when creating ARKitSceneView
@olexale I'm using this plugin and change it a bit, so i changed the plugin a bit and how it works is: when i open the plugin it will make the plane and for the object to appear I have to click on the area i want it. The 3d object is only 1 dae file, that have everything in it, dont need more files like the idleFixed.dae. But the plugin has a bug which is that: it loads the 3D object but doesn't load the textures of the object. I tested the code with the custom_object_page.dart and it works fine, but as I said I changed the code and when showing the object it comes without textures. already tested with iphone 7 and ipad.
same object with the code from custom_object_page.dart works 100% same object with the code bellow, the textures don't work:
code that I use and don't load the textures of object :
import 'package:arkit_plugin/arkit_plugin.dart'; import 'package:flutter/material.dart'; import 'package:vector_math/vector_math_64.dart' as vector; import "dart:math" as math;
class CustomObjectPage extends StatefulWidget { @override _CustomObjectPageState createState() => _CustomObjectPageState(); }
class _CustomObjectPageState extends State {
ARKitController arkitController;
ARKitReferenceNode node;
String anchorId;
ARKitNode nodePanoDourado = null, boxNode;
ARKitPlane plane;
@override void dispose() { arkitController?.dispose(); super.dispose(); }
@override Widget build(BuildContext context) => Scaffold( appBar: AppBar(title: const Text('Custom object on plane Sample')), body: Container( child: ARKitSceneView( showFeaturePoints: false, planeDetection: ARPlaneDetection.horizontal, //onARKitViewCreated: onARKitViewCreated, enableTapRecognizer: true,
void onARKitViewCreated(ARKitController arkitController) { this.arkitController = arkitController; //this.arkitController.onAddNodeForAnchor = _handleAddAnchor; this.arkitController.onNodePan = (pan) => _onPanHandler(pan); this.arkitController.onUpdateNodeForAnchor = _handleUpdateAnchor;
}
void _handleUpdateAnchor(ARKitAnchor anchor) { if (anchor.identifier != anchorId) { return; } final ARKitPlaneAnchor planeAnchor = anchor; nodePanoDourado.position = vector.Vector3(planeAnchor.center.x, 0, planeAnchor.center.z); //print("55555555"); plane.width.value = planeAnchor.extent.x; plane.height.value = planeAnchor.extent.z; //print("333333333");
}
void _onPanHandler(List pan) {
final panNode = pan.firstWhere((e) => boxNode.name == boxNode.name, orElse: null);
}
void _onARTapHandler(ARKitTestResult point) { final position = vector.Vector3( point.worldTransform.getColumn(3).x, point.worldTransform.getColumn(3).y, point.worldTransform.getColumn(3).z, );
}
void _handleAddAnchor(ARKitAnchor anchor) { if (anchor is ARKitPlaneAnchor) { _addPlane(arkitController, anchor); } }
void _addPlane(ARKitController controller, ARKitPlaneAnchor anchor) { anchorId = anchor.identifier; if (node != null) { controller.remove(node.name); } node = ARKitReferenceNode( //url: 'models.scnassets/dash.dae', url: 'models.scnassets/30.dae', scale: vector.Vector3.all(0.02), ); controller.add(node, parentNodeName: anchor.nodeName); } }