Visual Transform Cues

I am glad to announce a new enhancement in 3DTin editor that will make it more intuitive to apply transforms, i.e. rotation/scale/shear operations.

You can see the Visual Transform Cues in following screenshots or try them out yourself.

Protractor for Rotation transform

 

Directional arrows for Scaling

 

Directional arrows for Shear

These new visual aides will give you hint about the direction and/or magnitude of the transform that you are about to perform. You will also be able to change the planes of transforms by simply clicking the X,Y,Z buttons, instead of having to cancel the dialog and reorienting the view.

We look forward to your feedback.

Posted in Uncategorized | Leave a comment

Premium feature: Symmetry and Super Symmetry

We are glad to announce a new feature that will exactly halve your efforts while building symmetric models.

Long back we had implemented a mirror tool that was used to draw cubes symmetrically. After we added support for template based geometries, we didn’t get a chance extend that functionality to new geometries. Recently we found many 3DTin users building symmetric models. It occured to us that we can make their task remarkably easier if we allow a mode that automatically mirrors all the operations that users do in the other half of the model. Thus was born the idea for this new feature. Since this feature is mainly useful for power users we are offering it as a Premium feature.

There are two different ways in which this feature can be used.

1. Symmetric Add

In the left bottom corner you have seen the mirror icon (Club). In a regular sketch you can toggle it into two modes.

When the Symmetric Add is ON, for any geometry or cubes (voxels) that you add to the model, a mirror image is automatically added for you. In the past this feature was limited to cubes, but now it is available for all kinds of geometry. The mirroring is only restricted to add operation in this mode.

2. Super Symmetry

When you create a new sketch, you will now be prompted for which kind of model you want to create – Regular or Super Symmetric.

If you choose “Super Symmetric”, 3DTin assumes that you are building a completely symmetric model and it mirrors each and every operation you perform automatically.

Here is a short clip explaining how that looks.

As you can see, not just adding of geometry, but also all the subsequent operations – moving, rotating, grouping, aligning – are exactly replicated in the mirror image.

We very much hope that this new feature will help you make more awesome models with less amount of effort.

Note that you cannot add any asymmetric features to the super-symmetric model. But that can be easily worked around. You can build all the symmetric parts of your model in one sketch, then create a fresh regular asymmetric sketch and import the symmetric sketch into it. Best of both the worlds.

You will have to be a premium user for all the symmetric effects to actually take effect. If you are not, you will see a preview of the mirror geometry being added, but it won’t be actually added when you click.

Give it a try. We look forward to your feedback.

Posted in Uncategorized | Leave a comment

Soon going WebGL-only

Last year when we collected stats about how many of our visitors have WebGL enabled browsers, the number was around 55%. Nearly half of our visitors didn’t have WebGL back then. For all those users 3DTin automatically used to fallback to Canvas 2D backend and offer limited set of 3D modeling features.

The world of web browsers has come a long way since then. In past couple of weeks when we collected the same stats, we found that now nearly 92% of our visitors have WebGL enabled browsers. This is a huge boost. My guess is that the growing popularity of Google Chrome and its support of WebGL on machines without graphics card has contributed to this tremendous rise in WebGL users. Whatever might be the reason, the result is very promising.

In the light of these new numbers, it seems to be the right time to drop Canvas 2D backend support. We will be doing that in next few days. The users visiting 3DTin through non-webgl browser will see an error screen that will inform them about WebGL upgrade. Note that, all your models from the past are safe and sound on 3DTin servers, you only need a WebGL enabled browser to access them.

This will help reduce 3DTin javascript code that downloads into the browser. It will also simplify our data structures and make the WebGL backend more efficient.

Do let us know if you have any questions.

Posted in Uncategorized | 7 Comments

For better communication across different languages

We have users from all over the world speaking different languages. Therefore in group chat and comments, it sometimes becomes difficult to communicate. It shouldn’t be so difficult in the world of such awesome language tools as Google Translate.

We have added a tiny feature that will solve this problem somewhat.

On every comment and group chat entry you will now see a Translate link as you hover the mouse over it. This link will open Google translate with the translation of the message. The link automatically chooses the destination language for translation to match the locale you have set in 3DTin.

Here, try yourself.

Posted in Uncategorized | Leave a comment

Geometry Builder (featuring CSG Subtraction)

Over past several months we’ve got questions about why don’t we support CSG subtraction. I know it’s very frustrating to see all those solids and not be able to subtract one from other. :D

Well your wait is over. Today we are introducing Geometry Builder which lets you do just that. Here’s a screenshot that should explain the idea in a glance.

Now let me explain the details of how it works. But before that, let me explain why we took so long.

We have long been using the Cadmium solid modeling library that we open sourced last year to do CSG boolean operations on the server. That is how we build all the templates that you can customize and add to your models. But offering these CSG operations in interactive environments inside the browser is a different ball game.

  1. CSG algorithms are expensive, they are too slow for meaningful interaction
  2. They have to be run on server, so the interactivity suffers depending upon speed of your network connection
  3. The nature of boolean operations makes the interaction strategy difficult (How do you move a solid that is to be subtracted or in other words is invisible)

Of course others have already tried to solve this problem, on desktop as well as in browser. However we had to implement a solution that will solve all of the above problems and will be cheap at the same time. If we tried to run CSG algorithms on our servers while you manipulate the shapes in your browser, we will have to make them super fast and scalable, which will require very expensive hardware/software setup. And still you will get sluggish response if your network is slow.

To solve these problems we invested some quality time earlier this year implementing a completely different solution. We implemented a CSG algorithm that runs in browser and runs very quickly. I wrote about it in the past when we introduced Interactive Template Editor. Since then we have improved the algorithm further to make it produce better results and fixed some issues that makes it run on all browsers and platforms that support WebGL (previously it had problems on Windows machines running WebGL via Angle).

Now we are using the same algorithm to give you interactive CSG editing.

If you want to build custom geometries by subtracting a set of solids from other, then you can click the new button in the Shapes bar – “Make your own geometry”

That will launch the Geometry Builder dialog. This is a mini editor, similar to the main editor you use. Its purpose however is very specific. It allows you to add only primitive geometries (Cylinder, Box, Sphere, Torus). After adding them you can click on them to change their properties (radius, height, etc) and apply different transforms (rotation, shear, scale, etc.). Most importantly you will see a checkbox named “Subtract”. If you check it, the geometry will go red in editor, but in the preview section you will see it subtracted from other solid. You can keep making changes to your geometries and the preview will update immediately reflecting the changes you make.

This approach has the benefit that you can manipulate the solid to be subtracted very easily, even though it’s meant to be hollow. You do the changes in the editor where you see this solid in red and the preview shows the subtracted solid as a hollow carved into another solid.

When you are happy with the results, click the Build button. Now the geometry will be shipped to the server and will be baked into a proper mesh that you can add to your model, this should happen within seconds. You can add any number of instances of this geometry to your main model. You can perform all the regular operations on it as well. If you want to make any changes to it in future, click on it and press the Edit icon. The geometry will be opened in the Geometry Builder in the state that you left it in before.

This feature opens up possibilities for really wild solid geometries. I can’t wait to see what you make of it.

As always, if you find any bugs, please drop us a note.

Posted in Uncategorized | 1 Comment

PostgreSQL Replication and Hot Standby – In Practice

This article describes how to setup PostgreSQL Replication and Hot Standby on two Amazon EC2 instances running Ubuntu. I spent good chunk of time learning these tricks in past two weeks, in order to implement High Availability solution for 3DTin database server. The standby node can take over when main node goes down, the way it did last month during electric outage of Amazon EC2′s East coast data centers. 3DTin was down for 6 hours during the outage and since then we have been implementing measures to avoid it from happening again in future. This post may help other web developers to build robust cloud backends as well.

The replication technique used here has become available in PostgreSQL only since version 9.1. There are several blog posts and few books that describe it, but they don’t explain everything that is necessary. I found the explanation of these setups in “PostgreSQL 9 Administration Cookbook” very useful. I tried all the replication recipes described in that book on two VMs on my laptop. After going through 7 different database clusters, each used for testing different recipe, I got a good handle on the things. Today we’ve successfully set up this replication solution on 3DTin production database. With the details fresh in mind I would like to document all the steps for future reference and in the hope that it may also help others, given that the documentation on this topic is not yet abundant.

Setup

The instructions here use Ubuntu 11.10 32-bit server, with PostgreSQL 9.1.4 (Ubuntu 12.04 will do as well with any PostgreSQL version 9.1.x).

We are going to prepare 2 hosts, one master and another standby. If you are using Amazon EC2 like us, you want to run these two hosts in two different Availability zones. That is important if your goal is High Availability. Any accidental downtime is not supposed to affect more than one Amazon EC2 availability zones simultaneously. Therefore if one of the host goes down, you can bring up your application servers in another zone where your standby DB server is running. You can also put them in two different regions, but that will cost you more in networking bandwidth.

Preparation

Install following packages on Ubuntu 11.10/12.04

postgresql-9.1
postgresql-client-9.1
postgresql-contrib-9.1

postgres user account

Installing these packages will automatically create postgres user account.

All following commands are supposed to be executed as postgres user. For security reasons this account doesn’t have any password (like the root account on Ubuntu). If you are working in test environment you can set a password for postgres with

sudo passwd postgres

Then perform all following commands by logging in as postgres

su - postgres

If you are on production server though, you may want to leave postgres passwordless. Instead run all following commands with sudo -u postgres prepended. I am going to omit it from every command for convenience.

Password-less ssh logins

MASTER server should be able to access STANDBY over ssh without password. More accurately – postgres account on MASTER should be able to access postgres account on STANDBY without password. This is needed for the rsync operation in base-backup step (explained below)

You can do it using ssh-copy-id utility.

On master run
ssh-copy-id <IP_OF_STANDBY_SERVER>

You can also specify user in above command, but I deliberately omitted it because it is recommended that on both machines you do these operations under same user account postgres. Not mentioning the user will make the command login to remote machine with same username as you are currently logged in on this machine (or mentioned in sudo -u).

In case of failover, MASTER server and STANDBY server will be switching roles, therefore run ssh-copy-id from current STANDBY server, so that it can access current MASTER server without password too.

Ubuntu specific PostgreSQL conventions

On ubuntu a PostgreSQL database instance is called cluster. Don’t confuse it with multi-node configuration of servers or even a certain SQL keyword. It’s simply an instance of PostgreSQL server that runs on a particular port and saves its data in its own directory (default being /var/lib/postgresql/9.1/<cluster-name> - also set to PGDATA environment variable in various scripts).

Ubuntu comes with pg_createcluster, pg_ctlcluster, pg_lscluster CLI commands to help you administer these clusters. You will use pg_ctlcluster to start, stop, reload the database instance.

Each cluster also has its own set of configuration files stored in /etc/postgresql/9.1/<cluster-name>. We will need to modify only two of them: pg_hba.conf and postgresql.conf.

For keeping things simple, it’s better if you ensure that $PGDATA is same on both MASTER and STANDBY servers. (Side note: On production server $PGDATA is expected to be mounted on a separate volume)

Replication with Streaming Log Shipping and Hot Standby

There are many different configurations that you can follow to achieve replication across two PostgreSQL instances. Each has its own benefits and pitfalls. The technique we are going to use is known as ‘Streaming Log Shipping’ and ‘Hot Standby’ in the Admin cookbook I referred to earlier. This setup seems most optimal in terms of immediate replication (i.e. smallest window of data loss) and minimum networking traffic (hence cheaper).

This configuration is of Master-Slave kind. The Slave or STANDBY server can be used to query the database, but you cannot make any writes to it. This configuration is NOT what is known as “Multi Master” configuration. The Master will accept all read and write queries from your application servers. The Standby server will copy the new modifications from Master with minimal delay. It will only be available for read-only queries while in Standby mode. When the Master goes down or we bring it down for other reasons, we can tell the Standby server to become the Master by creating a touch file (explained later). After this point the ex-Standby server will stop following the original Master and will now be ready to accept read-write queries, it will then be the new Master.

Let’s start

If you already have a PostgreSQL database running on production server, that will be your current MASTER server. But note that we are going to configure both MASTER and STANDBY machines as identically as possible, because you will want to make any one of them MASTER in case another goes down and switch back when it comes back up.

Let’s start with current MASTER running and STANDBY stopped.

On the MASTER create replicator user. The STANDBY server will login to the MASTER using this account to read latest changes that it has to replicate. You should not do this step on current STANDBY server, even if it may sometime become a new Master. That is because during the base backup step the replicator user role will get copied to STANDBY server automatically.

psql -c "CREATE USER replicator SUPERUSER LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD 'changeme';"

Modify pg_hba.conf on both MASTER and STANDBY server by adding this line. This tells respective PostgreSQL instances to accept connection from other node for replication purposes.

host  replication replicator <IP_OF_OTHER_HOST>/32  md5

Modify postgresql.conf on both MASTER and STANDBY servers and add following lines to it. (Check if these options are already set to different values elsewhere in the file)

hot_standby = on
max_wal_senders = 1
wal_level = 'hot_standby'
archive_mode = on
archive_command = 'cd .'
listen_addresses = 'localhost,<IP_ADDRESS_OF_THIS_NODE>'

At this point restart MASTER. Do NOT start STANDBY yet

Next we are going to perform base backup from MASTER to STANDBY

BACKUP_LABEL="base-backup"

psql -p $PORT -c "select pg_start_backup('$BACKUP_LABEL');"
rsync -cva --inplace --exclude=*pg_xlog* $PGDATA/ <IP_OF_OTHER_HOST>:$PGDATA/
psql -p $PORT -c "select pg_stop_backup();"

It’s advised that you put this in a bash script so that it can be run quickly and repeatedly without any errors.

On STANDBY create a recovery.conf file in $PGDATA directory and add following lines to it.

standby_mode = 'on'
primary_conninfo = 'host=<IP_OF_OTHER_HOST> port=$PORT user=replicator password=changeme'
trigger_file = '/tmp/postgresql.trigger.$PORT'

Now start the STANDBY server.

At this point you can check the log file (/var/log/postgresql/postgresql-9.1-<cluster-name>.log) to verify things

  • On STANDBY look for a message “streaming replication successfully connected to primary”.
  • Also you should see “wal receiver process” on STANDBY and “wal sender process” on MASTER.
  • Finally run some queries against the STANDBY server to verify it contains same data as MASTER.

If it’s not working, check the firewall rules in Amazon EC2 Security Groups.

How to do Failover/Switchover

Setting up the system for high availability is of no use, if you are going to wait for actual disaster to strike before trying the recovery. Therefore you should try above steps in test environment and simulate disasters.

If MASTER is not down, make sure you stop it first, before you tell STANDBY to take up that role. This is to avoid the MASTER from processing further queries leading to a split-brain problem.

You can turn the STANDBY into a MASTER by simply touching a trigger file that was mentioned in the recovery.conf, /tmp/postgresql.trigger.$PORT.

Now that STANDBY has turned into MASTER, point your application servers to it. Even if your old MASTER is running at this point, the new MASTER is not going to replicate any changes from it. Therefore it is necessary that you stop the old MASTER before you ask the STANDBY to become the new MASTER.

You can tell that STANDBY has become MASTER from the messages in the log that read “archive recovery complete. database system is ready to accept connections.”

How to do Switchback

After some downtime or maintenance period, your master node is back up again and you want to do switchback. You are going to first turn this node into a standby. In this mode it will catch up with the current MASTER replicating the changes that took place while it was down. So we refer to it as current STANDBY now.

Peform Base backup from current MASTER to current STANDBY

BACKUP_LABEL="base-backup"

psql -p $PORT -c "select pg_start_backup('$BACKUP_LABEL');"
rsync -cva --inplace --exclude=*pg_xlog* $PGDATA/ <IP_OF_OTHER_HOST>:$PGDATA/
psql -p $PORT -c "select pg_stop_backup();"

Create recovery.conf in $PGDATA on current STANDBY

standby_mode = 'on'
primary_conninfo = 'host=<IP_OF_OTHER_HOST> port=$PORT user=replicator password=changeme'
trigger_file = '/tmp/postgresql.trigger.$PORT'

After the catch up is over, you can turn the current STANDBY into MASTER by following above switchover procedure – touch the trigger file.

In addition to being an insurance against disasters, the STANDBY server can also be used for load balancing purposes. You can configure the app servers to spread their read queries across the Master and Standby servers. Tools like pgpool provide that kind of facility.

Once you get comfortable setting up a basic two node replication and hot standby scheme, you can move on to advanced configurations too.

If you find any mistakes or suggestions for improvements in this article please leave a comment.

 

Posted in Development | Tagged | 15 Comments

Premium feature: Mix sketches by importing one into another

We have always supported and encouraged refining and deriving from existing sketches. But what if someone wants to use parts from multiple sketches into their derivative work? During my chat with @icevipergt and @Akin (two of our Ace users) in 3DTin’s chat room, I was requested many features, this being the first one. Also as the models created with 3DTin are growing in size, it is becoming more desirable to be able to import only select parts of them into other sketches. Today we are glad to introduce this ability as a Premium feature.

Let me describe how this feature works in four steps. I am going to use Akin’s fantastic 3D model “Bender”. I will import some parts of this model into another fresh model.

1. This step is not exactly necessary for importing, but is recommended. It has also been there for some time now. Group different parts of your model and give them names. I am going to name different parts of Bender’s body accordingly, so that we can import them selectively into our new sketch.

2. Now let’s create a new sketch and try to import some of Bender’s body parts into it. In the new design of the file browser you will see an import icon. I click it to import Bender’s parts into our sketch.

3. 3DTin now loads and analyzes Bender’s model and detects different groups that I  created earlier. If you have named them like I did, it will be easy for you to select them for import. You can also import entire sketch if you want. I will select both the legs for import.

4. The parts are now loaded and turn into their ghost image. Now I find a good spot in my empty sketch and place this pair of legs simply by clicking there.

There you go.

And when you save this sketch 3DTin maintains a member-container relationship between the sketch that was imported and the sketch to which it was imported. That way when the derivative work gets ratings, 3DTin will credit a fraction of that rating to the sketches that contributed to it.

With the new ability of mixing sketches like this, you can organize your work in multiple sketches and then use and reuse them in other sketches. For example, you can design different sets of wheels in separate files and try them on the main body of your muscle car which is in another sketch. This feature also makes sharing between the community possible at more granular level.

Give it a try and let us know your feedback.

(As I mentioned before, this is a premium feature. Hurry up and upgrade if you haven’t already. We are soon going to increase the prices.)

Posted in Uncategorized | 1 Comment