Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8196461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:29:10+00:00 2026-06-07T05:29:10+00:00

So I see a couple good working examples of using the mouse to drag

  • 0

So I see a couple good working examples of using the mouse to drag an object in Alternativa3d:

http://wonderfl.net/c/hrsq/read

http://www.thetechlabs.com/3d/dragging-3d-objects-in-flex-3-using-alternativa3d-and-actionscript-3/

but they are for previous versions of the engine, and they contain code that is now deprecated, with no straightforward forward-translation, if you will. Please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:29:11+00:00Added an answer on June 7, 2026 at 5:29 am

    Here is a version i made using alternativa3d 8.27.0 based on the wonderfl example you posted. Hope it helps..

    package {
    
    import alternativa.engine3d.core.events.MouseEvent3D;
    import alternativa.engine3d.core.RayIntersectionData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.display.Stage3D;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import alternativa.engine3d.primitives.Box;
    import alternativa.engine3d.core.Resource;
    import alternativa.engine3d.controllers.SimpleObjectController;
    import alternativa.engine3d.core.Camera3D;
    import alternativa.engine3d.core.Object3D;
    import alternativa.engine3d.core.View;
    import alternativa.engine3d.materials.FillMaterial;
    import flash.events.MouseEvent;
    import flash.geom.Vector3D;
    
    /**
     * ...
     * @author David E Jones
     */
    public class Main extends Sprite 
    {
        private var scene:Object3D = new Object3D();
        private var camera:Camera3D;
        private var controller:SimpleObjectController;
        private var stage3D:Stage3D;
        private var box:Box;
        private var boxSelected:Boolean = false;
        private var startPoint:Vector3D;
    
        public function Main():void 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
    
        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
    
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
    
            camera = new Camera3D(1, 1000);
            camera.view = new View(stage.stageWidth, stage.stageHeight, false, 0, 0, 4);
            camera.view.backgroundColor = 0x000000;
            addChild(camera.view);
            addChild(camera.diagram);
    
            camera.x = -30;
            camera.y = -30;
            camera.z = 0;
            controller = new SimpleObjectController(stage, camera, 200);
            controller.lookAt(new Vector3D(0,0,0));
            scene.addChild(camera);
    
            stage3D = stage.stage3Ds[0];
            stage3D.addEventListener(Event.CONTEXT3D_CREATE, onContextCreate);
            stage3D.requestContext3D();
        }
    
        private function onContextCreate(e:Event):void {
            stage3D.removeEventListener(Event.CONTEXT3D_CREATE, onContextCreate);
    
            box = new Box(10, 10, 10, 1, 1, 1, false, null);
            var material:FillMaterial = new FillMaterial( 0xFF0000 );
            box.setMaterialToAllSurfaces(material);
            scene.addChild(box);
            uploadResources(box.getResources(true));
    
            box.addEventListener(MouseEvent3D.MOUSE_DOWN, onMouseDown);
    
            stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
            stage.addEventListener(Event.RESIZE, onResize);
            onResize();
        }
    
        private function onMouseDown(e:MouseEvent3D):void 
        {
            stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
            stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
    
            var object:Object3D = e.target as Object3D;
            var origin:Vector3D = new Vector3D();
            var direction:Vector3D = new Vector3D();
            camera.calculateRay(origin, direction, stage.mouseX, stage.mouseY);
            var data:RayIntersectionData = object.intersectRay(origin, direction);
    
            if (data != null) {
                startPoint = data.point;
            }
        }
    
        private function onMouseUp(e:MouseEvent):void
        {
            stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
            stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
        }
    
        private function onMouseMove(e:MouseEvent):void
        {
            var origin:Vector3D = new Vector3D;
            var directionA:Vector3D = new Vector3D;
            var directionB:Vector3D = new Vector3D;
            var direction:Vector3D = new Vector3D;
    
            camera.calculateRay(origin, directionA, camera.view.width/2, camera.view.height/2);
            camera.calculateRay(origin, directionB, mouseX, mouseY);
    
            var pos : Vector3D = intersectionPoint(origin, directionB, new Vector3D(0, startPoint.y, 0), new Vector3D(0, 1, 0));
            box.x = pos.x-startPoint.x;
            box.y = pos.y-startPoint.y;
            box.z = pos.z-startPoint.z;
        }
    
        public static function intersectionPoint(lineStart:Vector3D, lineDirection:Vector3D, planePosition:Vector3D, planeNormal:Vector3D):Vector3D {
    
            var result:Vector3D = new Vector3D();
            var w:Vector3D = lineStart.subtract(planePosition);
            var d:Number = planeNormal.dotProduct(lineDirection);
            var n:Number = -planeNormal.dotProduct(w);
    
            if (Math.abs(d) < 0.0000001) return result;    
    
            var sI:Number = n / d;
    
            result.x = lineStart.x + (lineDirection.x * sI);
            result.y = lineStart.y + (lineDirection.y * sI);
            result.z = lineStart.z + (lineDirection.z * sI);
    
            return result;    
        }
    
        private function uploadResources(resources:Vector.<Resource>):void {
            for each (var resource:Resource in resources) {
                resource.upload(stage3D.context3D);
            }
        }
    
        private function onEnterFrame(e:Event):void {
            if (boxSelected) {
    
            }
            camera.render(stage3D);
        }
    
        private function onResize(e:Event = null):void {
            camera.view.width = stage.stageWidth;
            camera.view.height = stage.stageHeight;
        }
    }
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

See here: http://jsfiddle.net/zYcJm/ The jQuery should be validating each field to check if they
see fiddle I want to drag the mouse on cell and whatever is under
Scroll to the bottom, EDIT 19 onwards. See @Chris's comments also for good examples
I see a couple of previously answered questions about adding an item to an
I have a couple of questions. 1) Why cannot we see system tables (like
See Deepa answer for the solution :) I read all of the solution given
see fiddle if patient has time slot alloted already then make color yellow using
Does anyone have some links on some really good tutorials on asp.net MVC Areas?
I've been searching the net for a couple days now and haven't turned up
I've been working with the Restlet library for the last couple weeks and from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.