Пример #1
0
 public ValueTask set_pickInfo(PickingInfo value)
 {
     __pickInfo = null;
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "pickInfo",
                value
                ));
 }
Пример #2
0
        public static async ValueTask <PointerInfo> NewPointerInfo(
            decimal type, PointerEvent @event, PickingInfo pickInfo
            )
        {
            var entity = await EventHorizonBlazorInterop.New(
                new string[] { "BABYLON", "PointerInfo" },
                type, @event, pickInfo
                );

            return(new PointerInfo(entity));
        }
Пример #3
0
        public PointerInfo(
            decimal type, PointerEvent @event, PickingInfo pickInfo
            ) : base()
        {
            var entity = EventHorizonBlazorInterop.New(
                new string[] { "BABYLON", "PointerInfo" },
                type, @event, pickInfo
                );

            ___guid = entity.___guid;
        }
Пример #4
0
 public async ValueTask <PickingInfo> get_pickInfo()
 {
     if (__pickInfo == null)
     {
         __pickInfo = await EventHorizonBlazorInterop.GetClass <PickingInfo>(
             this.___guid,
             "pickInfo",
             (entity) =>
         {
             return(new PickingInfo()
             {
                 ___guid = entity.___guid
             });
         }
             );
     }
     return(__pickInfo);
 }
Пример #5
0
        /// <summary>
        /// </summary>
        /// <param name="ray">
        /// </param>
        /// <param name="fastCheck">
        /// </param>
        /// <returns>
        /// </returns>
        public virtual PickingInfo intersects(Ray ray, bool fastCheck = false)
        {
            var pickingInfo = new PickingInfo();

            if (this.subMeshes == null || this._boundingInfo == null || !ray.intersectsSphere(this._boundingInfo.boundingSphere) ||
                !ray.intersectsBox(this._boundingInfo.boundingBox))
            {
                return(pickingInfo);
            }

            if (!this._generatePointsArray())
            {
                return(pickingInfo);
            }

            IntersectionInfo intersectInfo = null;
            Array <SubMesh>  subMeshes;
            int len;

            if (this._submeshesOctree != null && this.useOctreeForPicking)
            {
                var worldRay      = Ray.Transform(ray, this.getWorldMatrix());
                var intersections = this._submeshesOctree.intersectsRay(worldRay);
                len       = intersections.Length;
                subMeshes = intersections;
            }
            else
            {
                subMeshes = this.subMeshes;
                len       = subMeshes.Length;
            }

            for (var index = 0; index < len; index++)
            {
                var subMesh = subMeshes[index];
                if (len > 1 && !subMesh.canIntersects(ray))
                {
                    continue;
                }

                var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck);
                if (currentIntersectInfo != null)
                {
                    if (fastCheck || intersectInfo == null || currentIntersectInfo.distance < intersectInfo.distance)
                    {
                        intersectInfo = currentIntersectInfo;
                        if (fastCheck)
                        {
                            break;
                        }
                    }
                }
            }

            if (intersectInfo != null)
            {
                var world       = this.getWorldMatrix();
                var worldOrigin = Vector3.TransformCoordinates(ray.origin, world);
                var direction   = ray.direction.clone();
                direction.normalize();
                direction = direction.scale(intersectInfo.distance);
                var worldDirection = Vector3.TransformNormal(direction, world);
                var pickedPoint    = worldOrigin.add(worldDirection);
                pickingInfo.hit         = true;
                pickingInfo.distance    = Vector3.Distance(worldOrigin, pickedPoint);
                pickingInfo.pickedPoint = pickedPoint;
                pickingInfo.pickedMesh  = this;
                pickingInfo.bu          = intersectInfo.bu;
                pickingInfo.bv          = intersectInfo.bv;
                pickingInfo.faceId      = intersectInfo.faceId;
                return(pickingInfo);
            }

            return(pickingInfo);
        }