• Home
  • User Manual
  • Tutorials
  • Updates
Search Results for

    Show / Hide Table of Contents
    • Welcome to twin
    • Getting Started
      • Install and uninstall twin
      • Install and uninstall a licence
      • Start twin
    • Simulation Component Library
      • Automation
        • ScriptComponent
        • Sequence
      • BitManipulator
        • BitsToBytesConverter
        • BytesToBitsConverter
        • EndiannessChanger
      • BooleanOperations
        • BooleanFunction
        • Invert
        • InputSwitch
      • ControlPanel
        • ControlPanel
      • Conveyor
        • Conveyor
        • VacuumConveyor
      • Debug
        • Counter
      • DataManipulator
        • DataReader
        • DataTypeConverter
        • DataWriter
      • FMU
        • FMU
      • Gripper
        • KinematicGripper
        • ObjectCoupler
        • VacuumGripper
      • HardwareConnector
        • PLCConnector
        • RobotControllerConnector
      • Math
        • Gain
        • LinearFunction
        • LowPassFilter
        • NumberComparer
        • Sum
      • Motor
        • FCControlledMotor
        • ServoMotor
      • Movers
        • BoolToSignedDirection
        • DynamicCylinder
        • DynamicRotationMover
        • DynamicTranslationMover
        • KinematicCylinder
        • KinematicPathMover
        • KinematicRotationMover
        • KinematicTranslationMover
      • ObjectManipulator
        • Colorizer
        • Object3DCutter
        • VisibilityChanger
      • Sensors
        • AngleLimitSwitch
        • CollisionObserver
        • DistanceSensor
        • DynamicObjectDetector
        • LightBarrier
        • PositionLimitSwitch
        • PositionTracker
      • Sinks
        • FileLogger
        • CollisionSink
        • RaySink
      • Sources
        • BoolConstant
        • BoxSource
        • DoubleConstant
        • Object3DFileSource
        • Object3DSource
        • RandomBoolean
        • RandomNumber
        • SinusGenerator
        • SphereSource
        • StringConstant
      • Timers
        • IntervalTrigger
        • TOF
        • TON
    • Collision Detection
      • What is essential for collision detection?
      • Where can I find the mesh simplifiers?
      • Which mesh simplification methods are available?
    • twin Mirror
      • Install the twin Mirror
      • Embed the twin Mirror into your HMI
      • React on user-events
      • Manipulate 3D objects
      • Add labels and buttons
    • Video Guides
      • Install twin
      • How to handle twin
      • Organize projects
      • Import CAD files
      • Handle 3D objects
      • Organize simulation components
      • Activate physics in your simulation
      • Simulate conveyor systems
      • Simulate cylinders
      • Simulate axis systems and portals
      • Simulate sensors
      • Simulate grippers
      • Create program sequences
      • Connect to PLCs
      • Simulate robots
      • Model complex mechanical motion systems
      • Debug and analyse signals in twin
      • Best practices for maintenance efficient project development
      • FAQ

    Embed the twin Mirror into your HMI

    This shows how the twin mirror is embedded in your system.

    Setting up twin Mirror

    Integration of required JavaScript files

    The integration starts by including the twin.js library via the <script> tag in the HTML head:

    <script src="./js/twin.min.js"></script>
    

    HTML structure

    The HTML structure is straightforward, consisting of a container <div> acting as the canvas where the 3D content will be rendered.

    <div id="twinMirror"></div>
    

    CSS styling

    CSS is applied to style the twinMirror div. The CSS ensures that the div takes up the full width and height of its parent container and hides any overflow content. This setup is good practice to define the display of the 3D scene.

    <style>
      #twinMirror {
        position: relative;
        width: 100%;
        height: 100%;
        overflow: hidden;
      }
    </style>
    

    Initializing the mirror

    The Twin.js library is initialized by creating a new instance of twinLibrary.Twin(). The start() method of this instance is called, specifying the twinMirror div as the container for the 3D scene and mirror URL. After this step, the mirror is already working and should display your twin project.

    <script>
      window.twin = new twinLibrary.Twin();
      window.twin.start("twinMirror", "http://localhost:3000");
    </script>
    

    Example

    The following code displays an example how the whole file could look like.

    <!DOCTYPE html>
    <html>
    <head>
      <script src="./js/twin.min.js"></script>
      <style>
        #twinMirror {
          position: relative;
          width: 100%;
          height: 100%;
          overflow: hidden;
        }
      </style>
    </head>
    <body>
      <div id="twinMirror"></div>
      <script>
        window.twin = new twinLibrary.Twin();
        window.twin.start("twinMirror", "http://localhost:3000");
      </script>
    </body>
    </html>
    
    In this article
    Back to top Copyright © Eberle Automatische Systeme GmbH & Co KG